Home | History | Annotate | Download | only in glsl

Lines Matching refs:state

61 detect_conflicting_assignments(struct _mesa_glsl_parse_state *state,
65 _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
67 _mesa_glsl_initialize_variables(instructions, state);
69 state->symbols->language_version = state->language_version;
71 state->current_function = NULL;
73 state->toplevel_ir = instructions;
88 state->symbols->push_scope();
90 foreach_list_typed (ast_node, ast, link, & state->translation_unit)
91 ast->hir(instructions, state);
93 detect_recursion_unlinked(state, instructions);
94 detect_conflicting_assignments(state, instructions);
96 state->toplevel_ir = NULL;
107 * \param state GLSL compiler state
115 struct _mesa_glsl_parse_state *state)
117 void *ctx = state;
124 if (state->language_version < 120)
167 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
179 _mesa_glsl_error(loc, state,
189 if (!apply_implicit_conversion(type_a, value_b, state)
190 && !apply_implicit_conversion(type_b, value_a, state)) {
191 _mesa_glsl_error(loc, state,
209 _mesa_glsl_error(loc, state,
252 _mesa_glsl_error(loc, state,
345 _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication");
352 _mesa_glsl_error(loc, state, "type mismatch");
359 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
370 _mesa_glsl_error(loc, state,
391 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
393 if (state->language_version < 130) {
394 _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30");
405 _mesa_glsl_error(loc, state, "LHS of `%s' must be an integer",
410 _mesa_glsl_error(loc, state, "RHS of `%s' must be an integer",
419 _mesa_glsl_error(loc, state, "operands of `%s' must have the same "
428 _mesa_glsl_error(loc, state, "operands of `%s' cannot be vectors of "
447 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
449 if (state->language_version < 130) {
450 _mesa_glsl_error(loc, state,
452 state->version_string);
462 _mesa_glsl_error(loc, state, "LHS of operator %% must be an integer.");
466 _mesa_glsl_error(loc, state, "RHS of operator %% must be an integer.");
470 _mesa_glsl_error(loc, state,
490 _mesa_glsl_error(loc, state, "type mismatch");
497 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
511 _mesa_glsl_error(loc, state,
521 if (!apply_implicit_conversion(type_a, value_b, state)
522 && !apply_implicit_conversion(type_b, value_a, state)) {
523 _mesa_glsl_error(loc, state,
532 _mesa_glsl_error(loc, state, "base type mismatch");
554 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
556 if (state->language_version < 130) {
557 _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30");
568 _mesa_glsl_error(loc, state, "LHS of operator %s must be an integer or "
574 _mesa_glsl_error(loc, state, "RHS of operator %s must be an integer or "
583 _mesa_glsl_error(loc, state, "If the first operand of %s is scalar, the "
595 _mesa_glsl_error(loc, state, "Vector operands to operator %s must "
624 validate_assignment(struct _mesa_glsl_parse_state *state,
653 if (apply_implicit_conversion(lhs_type, rhs, state)) {
672 do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
677 void *ctx = state;
686 _mesa_glsl_error(&lhs_loc, state,
692 _mesa_glsl_error(&lhs_loc, state,
697 } else if (state->language_version <= 110 && lhs->type->is_array()) {
704 _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not "
708 _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
714 validate_assignment(state, lhs->type, rhs, is_initializer);
716 _mesa_glsl_error(& lhs_loc, state, "type mismatch");
736 _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to "
792 struct _mesa_glsl_parse_state *state)
795 (void) state;
885 struct _mesa_glsl_parse_state *state,
892 void *ctx = state;
893 ir_rvalue *val = expr->hir(instructions, state);
900 _mesa_glsl_error(&loc, state, "%s of `%s' must be scalar boolean",
915 YYLTYPE loc, struct _mesa_glsl_parse_state *state)
918 && (size > state->Const.MaxTextureCoords)) {
924 _mesa_glsl_error(&loc, state, "`gl_TexCoord' array size cannot "
926 state->Const.MaxTextureCoords);
929 && size > state->Const.MaxClipPlanes) {
939 _mesa_glsl_error(&loc, state, "`gl_ClipDistance' array size cannot "
941 state->Const.MaxClipPlanes);
971 struct _mesa_glsl_parse_state *state)
973 void *ctx = state;
1039 op[0] = this->subexpressions[0]->hir(instructions, state);
1040 op[1] = this->subexpressions[1]->hir(instructions, state);
1042 result = do_assignment(instructions, state,
1051 op[0] = this->subexpressions[0]->hir(instructions, state);
1053 type = unary_arithmetic_result_type(op[0]->type, state, & loc);
1061 op[0] = this->subexpressions[0]->hir(instructions, state);
1063 type = unary_arithmetic_result_type(op[0]->type, state, & loc);
1075 op[0] = this->subexpressions[0]->hir(instructions, state);
1076 op[1] = this->subexpressions[1]->hir(instructions, state);
1080 state, & loc);
1088 op[0] = this->subexpressions[0]->hir(instructions, state);
1089 op[1] = this->subexpressions[1]->hir(instructions, state);
1091 type = modulus_result_type(op[0]->type, op[1]->type, state, & loc);
1102 if (state->language_version < 130) {
1103 _mesa_glsl_error(&loc, state, "operator %s requires GLSL 1.30",
1108 op[0] = this->subexpressions[0]->hir(instructions, state);
1109 op[1] = this->subexpressions[1]->hir(instructions, state);
1110 type = shift_result_type(op[0]->type, op[1]->type, this->oper, state,
1121 op[0] = this->subexpressions[0]->hir(instructions, state);
1122 op[1] = this->subexpressions[1]->hir(instructions, state);
1124 type = relational_result_type(op[0], op[1], state, & loc);
1140 op[0] = this->subexpressions[0]->hir(instructions, state);
1141 op[1] = this->subexpressions[1]->hir(instructions, state);
1152 if ((!apply_implicit_conversion(op[0]->type, op[1], state)
1153 && !apply_implicit_conversion(op[1]->type, op[0], state))
1155 _mesa_glsl_error(& loc, state, "operands of `%s' must have the same "
1158 } else if ((state->language_version <= 110)
1160 _mesa_glsl_error(& loc, state, "array comparisons forbidden in "
1176 op[0] = this->subexpressions[0]->hir(instructions, state);
1177 op[1] = this->subexpressions[1]->hir(instructions, state);
1179 state, &loc);
1186 op[0] = this->subexpressions[0]->hir(instructions, state);
1188 if (state->language_version < 130) {
1189 _mesa_glsl_error(&loc, state, "bit-wise operations require GLSL 1.30");
1194 _mesa_glsl_error(&loc, state, "operand of `~' must be an integer");
1204 op[0] = get_scalar_boolean_operand(instructions, state, this, 0,
1206 op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1,
1240 op[0] = get_scalar_boolean_operand(instructions, state, this, 0,
1242 op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1,
1281 op[0] = get_scalar_boolean_operand(instructions, state, this, 0, "LHS",
1283 op[1] = get_scalar_boolean_operand(instructions, state, this, 1, "RHS",
1291 op[0] = get_scalar_boolean_operand(instructions, state, this, 0,
1302 op[0] = this->subexpressions[0]->hir(instructions, state);
1303 op[1] = this->subexpressions[1]->hir(instructions, state);
1307 state, & loc);
1312 result = do_assignment(instructions, state,
1327 op[0] = this->subexpressions[0]->hir(instructions, state);
1328 op[1] = this->subexpressions[1]->hir(instructions, state);
1330 type = modulus_result_type(op[0]->type, op[1]->type, state, & loc);
1338 result = do_assignment(instructions, state,
1348 op[0] = this->subexpressions[0]->hir(instructions, state);
1349 op[1] = this->subexpressions[1]->hir(instructions, state);
1350 type = shift_result_type(op[0]->type, op[1]->type, this->oper, state,
1354 result = do_assignment(instructions, state,
1365 op[0] = this->subexpressions[0]->hir(instructions, state);
1366 op[1] = this->subexpressions[1]->hir(instructions, state);
1368 state, &loc);
1371 result = do_assignment(instructions, state,
1386 op[0] = get_scalar_boolean_operand(instructions, state, this, 0,
1397 op[1] = this->subexpressions[1]->hir(&then_instructions, state);
1398 op[2] = this->subexpressions[2]->hir(&else_instructions, state);
1409 if ((!apply_implicit_conversion(op[1]->type, op[2], state)
1410 && !apply_implicit_conversion(op[2]->type, op[1], state))
1414 _mesa_glsl_error(& loc, state, "Second and third operands of ?: "
1427 if ((state->language_version <= 110) && type->is_array()) {
1428 _mesa_glsl_error(& loc, state, "Second and third operands of ?: "
1473 op[0] = this->subexpressions[0]->hir(instructions, state);
1476 type = arithmetic_result_type(op[0], op[1], false, state, & loc);
1482 result = do_assignment(instructions, state,
1494 op[0] = this->subexpressions[0]->hir(instructions, state);
1499 type = arithmetic_result_type(op[0], op[1], false, state, & loc);
1510 (void)do_assignment(instructions, state,
1520 result = _mesa_ast_field_selection_to_hir(this, instructions, state);
1526 op[0] = subexpressions[0]->hir(instructions, state);
1527 op[1] = subexpressions[1]->hir(instructions, state);
1546 _mesa_glsl_error(& index_loc, state,
1553 _mesa_glsl_error(& index_loc, state,
1557 _mesa_glsl_error(& index_loc, state,
1605 _mesa_glsl_error(& loc, state, "%s index must be < %u",
1609 _mesa_glsl_error(& loc, state, "%s index must be >= 0",
1628 if (check_builtin_array_max_size(v->name, idx+1, loc, state))
1633 _mesa_glsl_error(&loc, state, "unsized array index must be constant");
1663 if (state->language_version == 100) {
1664 _mesa_glsl_warning(&loc, state,
1667 } else if (state->language_version < 130) {
1668 _mesa_glsl_warning(&loc, state,
1673 _mesa_glsl_error(&loc, state,
1700 state->symbols->get_variable(this->primary_expression.identifier);
1706 _mesa_glsl_error(& loc, state, "`%s' undeclared",
1763 _mesa_glsl_warning(&previous_operand_loc, state,
1776 result = ast->hir(instructions, state);
1789 _mesa_glsl_error(& loc, state, "type mismatch");
1797 struct _mesa_glsl_parse_state *state)
1809 expression->hir(instructions, state);
1819 struct _mesa_glsl_parse_state *state)
1822 state->symbols->push_scope();
1825 ast->hir(instructions, state);
1828 state->symbols->pop_scope();
1838 struct _mesa_glsl_parse_state *state)
1847 _mesa_glsl_error(loc, state,
1856 ir_rvalue *const ir = array_size->hir(& dummy_instructions, state);
1861 _mesa_glsl_error(& loc, state, "array size must be integer type");
1863 _mesa_glsl_error(& loc, state, "array size must be scalar type");
1868 _mesa_glsl_error(& loc, state, "array size must be a "
1871 _mesa_glsl_error(& loc, state, "array size must be > 0");
1886 } else if (state->es_shader) {
1890 _mesa_glsl_error(loc, state, "unsized array declarations are not "
1900 struct _mesa_glsl_parse_state *state) const
1904 type = state->symbols->get_type(this->type_name);
1909 type = process_array_type(&loc, type, this->array_size, state);
1919 struct _mesa_glsl_parse_state *state,
1925 _mesa_glsl_error(loc, state,
1936 || (qual->flags.q.varying && (state->target == fragment_shader)))
1942 if (qual->flags.q.attribute && state->target != vertex_shader) {
1944 _mesa_glsl_error(loc, state,
1947 _mesa_glsl_shader_target_name(state->target));
1966 _mesa_glsl_error(loc, state,
1977 || (qual->flags.q.varying && (state->target == fragment_shader)))
1980 || (qual->flags.q.varying && (state->target == vertex_shader)))
1985 if (state->all_invariant && (state->current_function == NULL)) {
1986 switch (state->target) {
2012 !(state->target == vertex_shader && var->mode == ir_var_out) &&
2013 !(state->target == fragment_shader && var->mode == ir_var_in)) {
2014 _mesa_glsl_error(loc, state,
2027 _mesa_glsl_error(loc, state,
2034 const bool global_scope = (state->current_function == NULL);
2044 switch (state->target) {
2053 _mesa_glsl_error(loc, state,
2067 _mesa_glsl_error(loc, state,
2070 _mesa_glsl_shader_target_name(state->target),
2083 var->location = (state->target == vertex_shader)
2101 _mesa_glsl_error(loc, state,
2110 _mesa_glsl_error(loc, state,
2147 state->ARB_fragment_coord_conventions_enable;
2151 _mesa_glsl_warning(loc, state,
2155 _mesa_glsl_error(loc, state,
2169 && !state->AMD_conservative_depth_enable
2170 && !state->ARB_conservative_depth_enable) {
2171 _mesa_glsl_error(loc, state,
2177 _mesa_glsl_error(loc, state,
2182 _mesa_glsl_error(loc, state,
2200 _mesa_glsl_error(loc, state,
2208 _mesa_glsl_error(loc, state,
2228 struct _mesa_glsl_parse_state *state)
2236 ir_variable *earlier = state->symbols->get_variable(decl->identifier);
2238 (state->current_function != NULL &&
2239 !state->symbols->name_declared_this_scope(decl->identifier))) {
2261 check_builtin_array_max_size(var->name, size, loc, state);
2263 _mesa_glsl_error(& loc, state, "array size must be > %u due to "
2271 } else if (state->ARB_fragment_coord_conventions_enable
2291 } else if (state->language_version >= 130
2303 } else if ((state->AMD_conservative_depth_enable ||
2304 state->ARB_conservative_depth_enable)
2314 _mesa_glsl_error(&loc, state,
2322 _mesa_glsl_error(&loc, state,
2333 _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier);
2346 struct _mesa_glsl_parse_state *state)
2358 if ((state->language_version <= 110)
2360 _mesa_glsl_error(& initializer_loc, state,
2365 _mesa_glsl_error(& initializer_loc, state,
2369 if ((var->mode == ir_var_in) && (state->current_function == NULL)) {
2370 _mesa_glsl_error(& initializer_loc, state,
2372 _mesa_glsl_shader_target_name(state->target),
2373 (state->target == vertex_shader)
2377 ir_dereference *const lhs = new(state) ir_dereference_variable(var);
2379 state);
2386 ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs, true);
2392 _mesa_glsl_error(& initializer_loc, state,
2400 var->constant_value = ir_constant::zero(state, var->type);
2407 _mesa_glsl_error(&initializer_loc, state,
2413 var->constant_value = ir_constant::zero(state, var->type);
2427 result = do_assignment(initializer_instructions, state,
2468 struct _mesa_glsl_parse_state *state)
2470 void *ctx = state;
2490 if (state->current_function != NULL) {
2491 _mesa_glsl_error(& loc, state,
2502 state->symbols->get_variable(decl->identifier);
2504 _mesa_glsl_error(& loc, state,
2507 } else if ((state->target == vertex_shader)
2509 _mesa_glsl_error(& loc, state,
2512 } else if ((state->target == fragment_shader)
2514 _mesa_glsl_error(& loc, state,
2518 _mesa_glsl_error(& loc, state,
2538 (void) this->type->specifier->hir(instructions, state);
2540 decl_type = this->type->specifier->glsl_type(& type_name, state);
2559 || state->error);
2562 _mesa_glsl_warning(&loc, state, "empty declaration");
2564 _mesa_glsl_error(&loc, state,
2581 _mesa_glsl_error(& loc, state,
2585 _mesa_glsl_error(& loc, state,
2594 state);
2614 if ((state->language_version < 130)
2615 && !state->ARB_explicit_attrib_location_enable
2616 && !state->ARB_fragment_coord_conventions_enable) {
2618 _mesa_glsl_error(& loc, state,
2621 decl->identifier, state->version_string);
2624 _mesa_glsl_error(& loc, state,
2627 decl->identifier, state->version_string);
2632 apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
2636 if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
2641 _mesa_glsl_error(& loc, state,
2644 } else if ((state->target == fragment_shader) &&
2649 _mesa_glsl_error(& loc, state,
2655 if (state->current_function != NULL) {
2677 _mesa_glsl_error(& loc, state,
2685 if (state->target == vertex_shader) {
2715 if (state->language_version > 120)
2719 _mesa_glsl_error(& loc, state,
2727 if (!error_emitted && (state->language_version <= 130)
2729 _mesa_glsl_error(& loc, state,
2744 if (state->language_version >= 130
2745 && state->target == vertex_shader
2746 && state->current_function == NULL
2751 _mesa_glsl_error(&loc, state, "If a vertex output is an integer, "
2764 if (state->language_version >= 130
2776 _mesa_glsl_error(&loc, state,
2790 if (state->language_version >= 130
2796 switch (state->target) {
2799 _mesa_glsl_error(&loc, state,
2806 _mesa_glsl_error(&loc, state,
2820 if (state
2823 && state->target == vertex_shader) {
2825 _mesa_glsl_error(&loc, state,
2833 && state->language_version != 100
2834 && state->language_version < 130) {
2836 _mesa_glsl_error(&loc, state,
2858 && !(var->type->is_sampler() && state->es_shader)
2863 _mesa_glsl_error(&loc, state,
2865 "%s types", state->es_shader ? ", integer, and sampler"
2877 _mesa_glsl_error(&loc, state, "samplers must be declared uniform");
2887 ir_variable *earlier = get_variable_being_redeclared(var, decl, state);
2892 &initializer_instructions, state);
2902 _mesa_glsl_error(& loc, state,
2919 _mesa_glsl_error(& loc, state,
2930 _mesa_glsl_error(& loc, state,
2947 if (!state->symbols->add_variable(var)) {
2949 _mesa_glsl_error(&loc, state, "name `%s' already taken in the "
2982 struct _mesa_glsl_parse_state *state)
2984 void *ctx = state;
2989 type = this->type->specifier->glsl_type(& name, state);
2993 _mesa_glsl_error(& loc, state,
2997 _mesa_glsl_error(& loc, state,
3019 _mesa_glsl_error(& loc, state,
3027 _mesa_glsl_error(& loc, state, "formal parameter lacks a name");
3035 type = process_array_type(&loc, type, this->array_size, state);
3039 _mesa_glsl_error(&loc, state, "arrays passed as parameters must have "
3050 apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc,
3061 _mesa_glsl_error(&loc, state, "out and inout parameters cannot contain samplers");
3080 && type->is_array() && state->language_version == 110) {
3081 _mesa_glsl_error(&loc, state, "Arrays cannot be out or inout parameters in GLSL 1.10");
3097 _mesa_glsl_parse_state *state)
3104 param->hir(ir_parameters, state);
3115 _mesa_glsl_error(& loc, state,
3122 emit_function(_mesa_glsl_parse_state *state, ir_function *f)
3131 state->toplevel_ir->push_tail(f);
3137 struct _mesa_glsl_parse_state *state)
3139 void *ctx = state;
3164 if ((state->current_function != NULL) && (state->language_version != 110)) {
3166 _mesa_glsl_error(&loc, state,
3179 _mesa_glsl_error(&loc, state,
3189 & hir_parameters, state);
3193 this->return_type->specifier->glsl_type(& return_type_name, state);
3197 _mesa_glsl_error(&loc, state,
3208 _mesa_glsl_error(& loc, state,
3219 _mesa_glsl_error(&loc, state,
3228 f = state->symbols->get_function(name);
3229 if (f != NULL && (state->es_shader || f->has_user_signature())) {
3236 _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' "
3243 _mesa_glsl_error(&loc, state, "function `%s' return type doesn't "
3250 _mesa_glsl_error(& loc, state, "function `%s' redefined", name);
3255 if (!state->symbols->add_function(f)) {
3259 _mesa_glsl_error(&loc, state, "function name `%s' conflicts with "
3264 emit_function(state, f);
3272 _mesa_glsl_error(& loc, state, "main() must return void");
3278 _mesa_glsl_error(& loc, state, "main() must not take any parameters");
3300 struct _mesa_glsl_parse_state *state)
3303 prototype->hir(instructions, state);
3309 assert(state->current_function == NULL);
3310 state->current_function = signature;
3311 state->found_return = false;
3316 state->symbols->push_scope();
3325 if (state->symbols->name_declared_this_scope(var->name)) {
3328 _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name);
3330 state->symbols->add_variable(var);
3335 this->body->hir(&signature->body, state);
3338 state->symbols->pop_scope();
3340 assert(state->current_function == signature);
3341 state->current_function = NULL;
3343 if (!signature->return_type->is_void() && !state->found_return) {
3345 _mesa_glsl_error(& loc, state, "function `%s' has non-void return type "
3359 struct _mesa_glsl_parse_state *state)
3361 void *ctx = state;
3366 assert(state->current_function);
3369 ir_rvalue *const ret = opt_return_value->hir(instructions, state);
3382 if (state->current_function->return_type != ret_type) {
3385 _mesa_glsl_error(& loc, state,
3389 state->current_function->function_name(),
3390 state->current_function->return_type->name);
3395 if (state->current_function->return_type->base_type !=
3399 _mesa_glsl_error(& loc, state,
3402 state->current_function->function_name());
3407 state->found_return = true;
3413 if (state->target != fragment_shader) {
3416 _mesa_glsl_error(& loc, state,
3425 state->loop_nesting_ast == NULL) {
3428 _mesa_glsl_error(& loc, state,
3431 state->loop_nesting_ast == NULL &&
3432 state->switch_state.switch_nesting_ast == NULL) {
3435 _mesa_glsl_error(& loc, state,
3443 if (state->loop_nesting_ast != NULL &&
3445 state->loop_nesting_ast->rest_expression) {
3446 state->loop_nesting_ast->rest_expression->hir(instructions,
3447 state);
3450 if (state->switch_state.is_switch_innermost &&
3452 /* Force break out of switch by setting is_break switch state.
3454 ir_variable *const is_break_var = state->switch_state.is_break_var;
3483 struct _mesa_glsl_parse_state *state)
3485 void *ctx = state;
3487 ir_rvalue *const condition = this->condition->hir(instructions, state);
3501 _mesa_glsl_error(& loc, state, "if-statement condition must be scalar "
3508 state->symbols->push_scope();
3509 then_statement->hir(& stmt->then_instructions, state);
3510 state->symbols->pop_scope();
3514 state->symbols->push_scope();
3515 else_statement->hir(& stmt->else_instructions, state);
3516 state->symbols->pop_scope();
3529 struct _mesa_glsl_parse_state *state)
3531 void *ctx = state;
3534 this->test_expression->hir(instructions, state);
3546 state,
3553 struct glsl_switch_state saved = state->switch_state;
3555 state->switch_state.is_switch_innermost = true;
3556 state->switch_state.switch_nesting_ast = this;
3557 state->switch_state.labels_ht = hash_table_ctor(0, hash_table_pointer_hash,
3559 state->switch_state.previous_default = NULL;
3561 /* Initalize is_fallthru state to false.
3564 state->switch_state.is_fallthru_var =
3568 instructions->push_tail(state->switch_state.is_fallthru_var);
3571 new(ctx) ir_dereference_variable(state->switch_state.is_fallthru_var);
3575 /* Initalize is_break state to false.
3578 state->switch_state.is_break_var = new(ctx) ir_variable(glsl_type::bool_type,
3581 instructions->push_tail(state->switch_state.is_break_var);
3584 new(ctx) ir_dereference_variable(state->switch_state.is_break_var);
3590 test_to_hir(instructions, state);
3594 body->hir(instructions, state);
3596 hash_table_dtor(state->switch_state.labels_ht);
3598 state->switch_state = saved;
3607 struct _mesa_glsl_parse_state *state)
3609 void *ctx = state;
3614 state);
3616 state->switch_state.test_var = new(ctx) ir_variable(test_val->type,
3620 new(ctx) ir_dereference_variable(state->switch_state.test_var);
3622 instructions->push_tail(state->switch_state.test_var);
3629 struct _mesa_glsl_parse_state *state)
3632 stmts->hir(instructions, state);
3640 struct _mesa_glsl_parse_state *state)
3643 case_stmt->hir(instructions, state);
3651 struct _mesa_glsl_parse_state *state)
3653 labels->hir(instructions, state);
3655 /* Conditionally set fallthru state based on break state. */
3656 ir_constant *const false_val = new(state) ir_constant(false);
3658 new(state) ir_dereference_variable(state->switch_state.is_fallthru_var);
3660 new(state) ir_dereference_variable(state->switch_state.is_break_var);
3662 new(state) ir_assignment(deref_is_fallthru_var,
3667 /* Guard case statements depending on fallthru state. */
3669 new(state) ir_dereference_variable(state->switch_state.is_fallthru_var);
3670 ir_if *const test_fallthru = new(state) ir_if(deref_fallthru_guard);
3673 stmt->hir(& test_fallthru->then_instructions, state);
3684 struct _mesa_glsl_parse_state *state)
3687 label->hir(instructions, state);
3695 struct _mesa_glsl_parse_state *state)
3697 void *ctx = state;
3700 new(ctx) ir_dereference_variable(state->switch_state.is_fallthru_var);
3706 /* Conditionally set fallthru state based on
3709 ir_rvalue *const label_rval = this->test_value->hir(instructions, state);
3715 _mesa_glsl_error(& loc, state,
3723 hash_table_find(state->switch_state.labels_ht,
3728 _mesa_glsl_error(& loc, state,
3732 _mesa_glsl_error(& loc, state,
3735 hash_table_insert(state->switch_state.labels_ht,
3742 new(ctx) ir_dereference_variable(state->switch_state.test_var);
3755 if (state->switch_state.previous_default) {
3757 _mesa_glsl_error(& loc, state,
3760 loc = state->switch_state.previous_default->get_location();
3761 _mesa_glsl_error(& loc, state,
3764 state->switch_state.previous_default = this;
3766 /* Set falltrhu state. */
3779 struct _mesa_glsl_parse_state *state)
3781 void *ctx = state;
3785 condition->hir(& stmt->body_instructions, state);
3791 _mesa_glsl_error(& loc, state,
3814 struct _mesa_glsl_parse_state *state)
3816 void *ctx = state;
3821 state->symbols->push_scope();
3824 init_statement->hir(instructions, state);
3830 ast_iteration_statement *nesting_ast = state->loop_nesting_ast;
3832 state->loop_nesting_ast = this;
3837 bool saved_is_switch_innermost = state->switch_state.is_switch_innermost;
3838 state->switch_state.is_switch_innermost = false;
3841 condition_to_hir(stmt, state);
3844 body->hir(& stmt->body_instructions, state);
3847 state);
3850 condition_to_hir(stmt, state);
3853 state->symbols->pop_scope();
3856 state->loop_nesting_ast = nesting_ast;
3857 state->switch_state.is_switch_innermost = saved_is_switch_innermost;
3867 struct _mesa_glsl_parse_state *state)
3875 && state->language_version != 100
3876 && state->language_version < 130) {
3877 _mesa_glsl_error(&loc, state,
3884 _mesa_glsl_error(&loc, state,
3904 _mesa_glsl_error(&loc, state,
3911 _mesa_glsl_error(&loc, state,
3922 return this->structure->hir(instructions, state);
3930 struct _mesa_glsl_parse_state *state)
3951 glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field,
3959 decl_list->type->specifier->hir(instructions, state);
3964 if (state->es_shader && decl_list->type->specifier->structure != NULL) {
3966 _mesa_glsl_error(&loc, state, "Embedded structure definitions are "
3971 decl_list->type->specifier->glsl_type(& type_name, state);
3979 state);
3994 if (!state->symbols->add_type(name, t)) {
3995 _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name);
3997 const glsl_type **s = reralloc(state, state->user_structures,
3999 state->num_user_structures + 1);
4001 s[state->num_user_structures] = t;
4002 state->user_structures = s;
4003 state->num_user_structures++;
4013 get_next_uniform_block(struct _mesa_glsl_parse_state *state)
4015 if (state->num_uniform_blocks >= state->uniform_block_array_size) {
4016 state->uniform_block_array_size *= 2;
4017 if (state->uniform_block_array_size <= 4)
4018 state->uniform_block_array_size = 4;
4020 state->uniform_blocks = reralloc(state,
4021 state->uniform_blocks,
4023 state->uniform_block_array_size);
4026 memset(&state->uniform_blocks[state->num_uniform_blocks],
4027 0, sizeof(*state->uniform_blocks));
4028 return &state->uniform_blocks[state->num_uniform_blocks++];
4033 struct _mesa_glsl_parse_state *state)
4039 struct gl_uniform_block *ubo = get_next_uniform_block(state);
4040 ubo->Name = ralloc_strdup(state->uniform_blocks, this->block_name);
4042 if (!state->symbols->add_uniform_block(ubo)) {
4044 _mesa_glsl_error(&loc, state, "Uniform block name `%s' already taken in "
4057 ubo->Uniforms = rzalloc_array(state->uniform_blocks,
4064 decl_list->hir(&declared_variables, state);
4072 var->uniform_block = ubo - state->uniform_blocks;
4074 ubo_var->Name = ralloc_strdup(state->uniform_blocks, var->name);
4076 ubo_var->Buffer = ubo - state->uniform_blocks;
4097 _mesa_glsl_error(&loc, state,
4109 detect_conflicting_assignments(struct _mesa_glsl_parse_state *state,
4132 if (state->target == fragment_shader &&
4156 _mesa_glsl_error(&loc, state, "fragment shader writes to both "
4159 _mesa_glsl_error(&loc, state, "fragment shader writes to both "
4163 _mesa_glsl_error(&loc, state, "fragment shader writes to both "