• Home
  • Raw
  • Download

Lines Matching +full:constant +full:- +full:conversion

50       ast->set_is_lhs(true);  in process_parameters()
51 ir_rvalue *result = ast->hir(instructions, state); in process_parameters()
55 actual_parameters->push_tail(ir_rvalue::error_value(mem_ctx)); in process_parameters()
60 ir_constant *const constant = in process_parameters() local
61 result->constant_expression_value(mem_ctx); in process_parameters()
63 if (constant != NULL) in process_parameters()
64 result = constant; in process_parameters()
66 actual_parameters->push_tail(result); in process_parameters()
94 str = ralloc_asprintf(NULL, "%s ", return_type->name); in prototype_string()
100 ralloc_asprintf_append(&str, "%s%s", comma, param->type->name); in prototype_string()
121 if (actual->data.memory_coherent && !formal->data.memory_coherent) { in verify_image_parameter()
124 "`coherent' qualifier", formal->name); in verify_image_parameter()
128 if (actual->data.memory_volatile && !formal->data.memory_volatile) { in verify_image_parameter()
131 "`volatile' qualifier", formal->name); in verify_image_parameter()
135 if (actual->data.memory_restrict && !formal->data.memory_restrict) { in verify_image_parameter()
138 "`restrict' qualifier", formal->name); in verify_image_parameter()
142 if (actual->data.memory_read_only && !formal->data.memory_read_only) { in verify_image_parameter()
145 "`readonly' qualifier", formal->name); in verify_image_parameter()
149 if (actual->data.memory_write_only && !formal->data.memory_write_only) { in verify_image_parameter()
152 "`writeonly' qualifier", formal->name); in verify_image_parameter()
164 (!var->is_in_shader_storage_block() && in verify_first_atomic_parameter()
165 var->data.mode != ir_var_shader_shared)) { in verify_first_atomic_parameter()
191 (var->data.image_format != PIPE_FORMAT_R32_UINT && in verify_atomic_image_parameter_qualifier()
192 var->data.image_format != PIPE_FORMAT_R32_SINT && in verify_atomic_image_parameter_qualifier()
193 var->data.image_format != PIPE_FORMAT_R32_FLOAT)) { in verify_atomic_image_parameter_qualifier()
231 foreach_in_list(const ir_variable, formal, &sig->parameters) { in verify_parameter_modes()
233 assert(!actual_ir_node->is_tail_sentinel()); in verify_parameter_modes()
234 assert(!actual_ast_node->is_tail_sentinel()); in verify_parameter_modes()
240 YYLTYPE loc = actual_ast->get_location(); in verify_parameter_modes()
243 if (formal->data.mode == ir_var_const_in && in verify_parameter_modes()
244 actual->ir_type != ir_type_constant) { in verify_parameter_modes()
246 "parameter `in %s' must be a constant expression", in verify_parameter_modes()
247 formal->name); in verify_parameter_modes()
252 if (formal->data.must_be_shader_input) { in verify_parameter_modes()
256 if (val->ir_type == ir_type_swizzle) { in verify_parameter_modes()
257 if (!state->is_version(440, 0)) { in verify_parameter_modes()
260 formal->name); in verify_parameter_modes()
263 val = ((ir_swizzle *)val)->val; in verify_parameter_modes()
267 if (val->ir_type == ir_type_dereference_array) { in verify_parameter_modes()
268 val = ((ir_dereference_array *)val)->array; in verify_parameter_modes()
269 } else if (val->ir_type == ir_type_dereference_record && in verify_parameter_modes()
270 !state->es_shader) { in verify_parameter_modes()
271 val = ((ir_dereference_record *)val)->record; in verify_parameter_modes()
277 if (const ir_dereference_variable *deref_var = val->as_dereference_variable()) in verify_parameter_modes()
278 var = deref_var->variable_referenced(); in verify_parameter_modes()
280 if (!var || var->data.mode != ir_var_shader_in) { in verify_parameter_modes()
283 formal->name); in verify_parameter_modes()
287 var->data.must_be_shader_input = 1; in verify_parameter_modes()
291 if (formal->data.mode == ir_var_function_out in verify_parameter_modes()
292 || formal->data.mode == ir_var_function_inout) { in verify_parameter_modes()
294 switch (formal->data.mode) { in verify_parameter_modes()
300 /* This AST-based check catches errors like f(i++). The IR-based in verify_parameter_modes()
302 * IR-level is just a temporary value, which is an l-value. in verify_parameter_modes()
304 if (actual_ast->non_lvalue_description != NULL) { in verify_parameter_modes()
307 mode, formal->name, in verify_parameter_modes()
308 actual_ast->non_lvalue_description); in verify_parameter_modes()
312 ir_variable *var = actual->variable_referenced(); in verify_parameter_modes()
314 if (var && formal->data.mode == ir_var_function_inout) { in verify_parameter_modes()
315 if ((var->data.mode == ir_var_auto || in verify_parameter_modes()
316 var->data.mode == ir_var_shader_out) && in verify_parameter_modes()
317 !var->data.assigned && in verify_parameter_modes()
318 !is_gl_identifier(var->name)) { in verify_parameter_modes()
320 var->name); in verify_parameter_modes()
325 var->data.assigned = true; in verify_parameter_modes()
327 if (var && var->data.read_only) { in verify_parameter_modes()
330 "read-only variable '%s'", in verify_parameter_modes()
331 mode, formal->name, in verify_parameter_modes()
332 actual->variable_referenced()->name); in verify_parameter_modes()
334 } else if (!actual->is_lvalue(state)) { in verify_parameter_modes()
337 mode, formal->name); in verify_parameter_modes()
341 assert(formal->data.mode == ir_var_function_in || in verify_parameter_modes()
342 formal->data.mode == ir_var_const_in); in verify_parameter_modes()
343 ir_variable *var = actual->variable_referenced(); in verify_parameter_modes()
345 if ((var->data.mode == ir_var_auto || in verify_parameter_modes()
346 var->data.mode == ir_var_shader_out) && in verify_parameter_modes()
347 !var->data.assigned && in verify_parameter_modes()
348 !is_gl_identifier(var->name)) { in verify_parameter_modes()
350 var->name); in verify_parameter_modes()
355 if (formal->type->is_image() && in verify_parameter_modes()
356 actual->variable_referenced()) { in verify_parameter_modes()
358 actual->variable_referenced())) in verify_parameter_modes()
362 actual_ir_node = actual_ir_node->next; in verify_parameter_modes()
363 actual_ast_node = actual_ast_node->next; in verify_parameter_modes()
367 const char *func_name = sig->function_name(); in verify_parameter_modes()
376 YYLTYPE loc = actual_ast->get_location(); in verify_parameter_modes()
379 actual->variable_referenced())) { in verify_parameter_modes()
389 YYLTYPE loc = actual_ast->get_location(); in verify_parameter_modes()
392 actual->variable_referenced())) { in verify_parameter_modes()
410 if (ir->ir_type == ir_type_dereference_array) { in copy_index_derefs_to_temps()
412 ir = a->array->as_dereference(); in copy_index_derefs_to_temps()
414 ir_rvalue *idx = a->array_index; in copy_index_derefs_to_temps()
415 ir_variable *var = idx->variable_referenced(); in copy_index_derefs_to_temps()
420 if (!var || var->data.read_only || var->data.memory_read_only) in copy_index_derefs_to_temps()
423 ir_variable *tmp = new(d->mem_ctx) ir_variable(idx->type, "idx_tmp", in copy_index_derefs_to_temps()
425 d->before_instructions->push_tail(tmp); in copy_index_derefs_to_temps()
428 new(d->mem_ctx) ir_dereference_variable(tmp); in copy_index_derefs_to_temps()
430 new(d->mem_ctx) ir_assignment(deref_tmp_1, in copy_index_derefs_to_temps()
431 idx->clone(d->mem_ctx, NULL)); in copy_index_derefs_to_temps()
432 d->before_instructions->push_tail(assignment); in copy_index_derefs_to_temps()
436 new(d->mem_ctx) ir_dereference_variable(tmp); in copy_index_derefs_to_temps()
437 a->array_index = deref_tmp_2; in copy_index_derefs_to_temps()
446 ir_expression *const expr = actual->as_expression(); in fix_parameter()
448 /* If the types match exactly and the parameter is not a vector-extract, in fix_parameter()
451 if (formal_type == actual->type in fix_parameter()
452 && (expr == NULL || expr->operation != ir_binop_vector_extract) in fix_parameter()
453 && actual->as_dereference_variable()) in fix_parameter()
459 if (!actual->as_dereference_variable()) { in fix_parameter()
468 * hold the value before conversion, and then perform the conversion after in fix_parameter()
486 * additional conversion is needed in the post-call re-write. in fix_parameter()
491 before_instructions->push_tail(tmp); in fix_parameter()
494 * parameter to the new temporary. Note that no type conversion is allowed in fix_parameter()
498 /* Inout parameters should never require conversion, since that would in fix_parameter()
499 * require an implicit conversion to exist both to and from the formal in fix_parameter()
502 assert (actual->type == formal_type); in fix_parameter()
507 new(mem_ctx) ir_assignment(deref_tmp_1, actual->clone(mem_ctx, NULL)); in fix_parameter()
508 before_instructions->push_tail(assignment); in fix_parameter()
516 actual->replace_with(deref_tmp_2); in fix_parameter()
520 * type conversion applied. in fix_parameter()
523 if (actual->type != formal_type) in fix_parameter()
524 rhs = convert_component(rhs, actual->type); in fix_parameter()
527 if (expr != NULL && expr->operation == ir_binop_vector_extract) { in fix_parameter()
528 lhs = new(mem_ctx) ir_dereference_array(expr->operands[0]->clone(mem_ctx, in fix_parameter()
530 expr->operands[1]->clone(mem_ctx, in fix_parameter()
535 after_instructions->push_tail(assignment_2); in fix_parameter()
541 * For non-void functions, this returns a dereference of the temporary
555 /* Perform implicit conversion of arguments. For out parameters, we need in generate_call()
556 * to place them in a temporary variable and do the conversion after the in generate_call()
558 * the post-call conversions in a temporary exec_list, and emit them later. in generate_call()
560 foreach_two_lists(formal_node, &sig->parameters, in generate_call()
565 if (formal->type->is_numeric() || formal->type->is_boolean()) { in generate_call()
566 switch (formal->data.mode) { in generate_call()
570 = convert_component(actual, formal->type); in generate_call()
571 actual->replace_with(converted); in generate_call()
576 fix_parameter(ctx, actual, formal->type, in generate_call()
578 formal->data.mode == ir_var_function_inout); in generate_call()
596 * Section 4.3.3 (Constant Expressions) of the GLSL 1.20.8 spec says: in generate_call()
598 * "A constant expression is one of in generate_call()
602 * - a built-in function call whose arguments are all constant in generate_call()
604 * functions, the noise functions, and ftransform. The built-in in generate_call()
606 * inside an initializer with an argument that is a constant in generate_call()
609 * Section 5.10 (Constant Expressions) of the GLSL ES 1.00.17 spec says: in generate_call()
611 * "A constant expression is one of in generate_call()
615 * - a built-in function call whose arguments are all constant in generate_call()
619 * Section 4.3.3 (Constant Expressions) of the GLSL ES 3.00.4 spec says: in generate_call()
621 * "A constant expression is one of in generate_call()
625 * - a built-in function call whose arguments are all constant in generate_call()
627 * functions. The built-in functions dFdx, dFdy, and fwidth must in generate_call()
629 * that is a constant expression." in generate_call()
631 * If the function call is a constant expression, don't generate any in generate_call()
634 if (state->is_version(120, 100) || in generate_call()
635 state->consts->AllowGLSLBuiltinConstantExpression) { in generate_call()
636 ir_constant *value = sig->constant_expression_value(ctx, in generate_call()
645 if (!sig->return_type->is_void()) { in generate_call()
648 ? ralloc_asprintf(ctx, "%s_retval", sig->function_name()) in generate_call()
653 var = new(ctx) ir_variable(sig->return_type, name, ir_var_temporary); in generate_call()
654 instructions->push_tail(var); in generate_call()
663 instructions->push_tail(call); in generate_call()
665 /* Also emit any necessary out-parameter conversions. */ in generate_call()
666 instructions->append_list(&post_call_conversions); in generate_call()
668 return deref ? deref->clone(ctx, NULL) : NULL; in generate_call()
679 ir_function *f = state->symbols->get_function(name); in match_function_by_name()
684 if (state->symbols->get_type(name)) in match_function_by_name()
688 if (!state->symbols->separate_function_namespace in match_function_by_name()
689 && state->symbols->get_variable(name)) in match_function_by_name()
693 /* In desktop GL, the presence of a user-defined signature hides any in match_function_by_name()
694 * built-in signatures, so we must ignore them. In contrast, in ES2 in match_function_by_name()
695 * user-defined signatures add new overloads, so we must consider them. in match_function_by_name()
697 bool allow_builtins = state->es_shader || !f->has_user_signature(); in match_function_by_name()
701 sig = local_sig = f->matching_signature(state, actual_parameters, in match_function_by_name()
710 /* Local shader has no exact candidates; check the built-ins. */ in match_function_by_name()
735 _mesa_shader_stage_to_subroutine_prefix(state->stage), in match_subroutine_by_name()
737 var = state->symbols->get_variable(new_name); in match_subroutine_by_name()
741 for (int i = 0; i < state->num_subroutine_types; i++) { in match_subroutine_by_name()
742 f = state->subroutine_types[i]; in match_subroutine_by_name()
743 if (strcmp(f->name, var->type->without_array()->name)) in match_subroutine_by_name()
752 sig = found->matching_signature(state, actual_parameters, in match_subroutine_by_name()
763 if (array->oper == ast_array_index) { in generate_array_index()
767 array->subexpressions[0], in generate_array_index()
768 array->subexpressions[1], in generate_array_index()
771 ir_rvalue *outer_array_idx = idx->hir(instructions, state); in generate_array_index()
773 YYLTYPE index_loc = idx->get_location(); in generate_array_index()
779 *function_name = array->primary_expression.identifier; in generate_array_index()
789 ir_rvalue *outer_array_idx = idx->hir(instructions, state); in generate_array_index()
798 ir_function *f = symbols->get_function(name); in function_exists()
800 foreach_in_list(ir_function_signature, sig, &f->signatures) { in function_exists()
801 if (sig->is_builtin() && !sig->is_builtin_available(state)) in function_exists()
816 foreach_in_list(ir_function_signature, sig, &f->signatures) { in print_function_prototypes()
817 if (sig->is_builtin() && !sig->is_builtin_available(state)) in print_function_prototypes()
820 char *str = prototype_string(sig->return_type, f->name, in print_function_prototypes()
821 &sig->parameters); in print_function_prototypes()
839 if (!function_exists(state, state->symbols, name) in no_matching_function_error()
840 && (!state->uses_builtin_functions in no_matching_function_error()
841 || !function_exists(state, sh->symbols, name))) { in no_matching_function_error()
852 state->symbols->get_function(name)); in no_matching_function_error()
854 if (state->uses_builtin_functions) { in no_matching_function_error()
856 sh->symbols->get_function(name)); in no_matching_function_error()
862 * Perform automatic type conversion of constructor parameters
864 * This implements the rules in the "Conversion and Scalar Constructors"
871 const unsigned a = desired_type->base_type; in convert_component()
872 const unsigned b = src->type->base_type; in convert_component()
875 if (src->type->is_error()) in convert_component()
1074 assert(result->type == desired_type); in convert_component()
1076 /* Try constant folding; it may fold in the conversion we just added. */ in convert_component()
1077 ir_constant *const constant = result->constant_expression_value(ctx); in convert_component() local
1078 return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; in convert_component()
1083 * Perform automatic type and constant conversion of constructor parameters
1086 * "Conversion and Scalar Constructors".
1088 * After attempting the implicit conversion, an attempt to convert into a
1089 * constant valued expression is also done.
1098 * If the attempt to convert into a constant expression succeeds, \c true is
1108 if (to != from->type->base_type) { in implicitly_convert_component()
1111 from->type->vector_elements, in implicitly_convert_component()
1112 from->type->matrix_columns); in implicitly_convert_component()
1114 if (from->type->can_implicitly_convert_to(desired_type, state)) { in implicitly_convert_component()
1116 * conversion rules (not the implicit conversion rules), its safe in implicitly_convert_component()
1118 * conversion is legal. in implicitly_convert_component()
1124 ir_rvalue *const constant = result->constant_expression_value(mem_ctx); in implicitly_convert_component() local
1126 if (constant != NULL) in implicitly_convert_component()
1127 result = constant; in implicitly_convert_component()
1130 from->replace_with(result); in implicitly_convert_component()
1134 return constant != NULL; in implicitly_convert_component()
1145 assert(component < src->type->components()); in dereference_component()
1147 /* If the source is a constant, just create a new constant instead of a in dereference_component()
1148 * dereference of the existing constant. in dereference_component()
1150 ir_constant *constant = src->as_constant(); in dereference_component() local
1151 if (constant) in dereference_component()
1152 return new(ctx) ir_constant(constant, component); in dereference_component()
1154 if (src->type->is_scalar()) { in dereference_component()
1156 } else if (src->type->is_vector()) { in dereference_component()
1159 assert(src->type->is_matrix()); in dereference_component()
1164 const int c = component / src->type->column_type()->vector_elements; in dereference_component()
1165 const int r = component % src->type->column_type()->vector_elements; in dereference_component()
1170 col->type = src->type->column_type(); in dereference_component()
1196 if (constructor_type->vector_elements <= 1) { in process_vec_mat_constructor()
1207 || (constructor_type->is_vector() && in process_vec_mat_constructor()
1208 constructor_type->vector_elements != parameter_count) in process_vec_mat_constructor()
1209 || (constructor_type->is_matrix() && in process_vec_mat_constructor()
1210 constructor_type->matrix_columns != parameter_count)) { in process_vec_mat_constructor()
1212 constructor_type->is_vector() ? "vector" : "matrix", in process_vec_mat_constructor()
1213 constructor_type->vector_elements); in process_vec_mat_constructor()
1222 * spec quote above!) and attempt to convert the parameter to a constant in process_vec_mat_constructor()
1224 * parameters to the constructor are trivially constant valued in process_vec_mat_constructor()
1228 implicitly_convert_component(ir, constructor_type->base_type, state); in process_vec_mat_constructor()
1230 if (constructor_type->is_matrix()) { in process_vec_mat_constructor()
1231 if (ir->type != constructor_type->column_type()) { in process_vec_mat_constructor()
1234 constructor_type->column_type()->name, in process_vec_mat_constructor()
1235 ir->type->name); in process_vec_mat_constructor()
1238 } else if (ir->type != constructor_type->get_scalar_type()) { in process_vec_mat_constructor()
1241 constructor_type->get_scalar_type()->name, in process_vec_mat_constructor()
1242 ir->type->name); in process_vec_mat_constructor()
1252 instructions->push_tail(var); in process_vec_mat_constructor()
1259 if (var->type->is_matrix()) { in process_vec_mat_constructor()
1265 assert(var->type->is_vector()); in process_vec_mat_constructor()
1271 instructions->push_tail(assignment); in process_vec_mat_constructor()
1310 bool is_unsized_array = constructor_type->is_unsized_array(); in process_array_constructor()
1313 (!is_unsized_array && (constructor_type->length != parameter_count))) { in process_array_constructor()
1315 ? 1 : constructor_type->length; in process_array_constructor()
1326 glsl_type::get_array_instance(constructor_type->fields.array, in process_array_constructor()
1329 assert(constructor_type->length == parameter_count); in process_array_constructor()
1333 const glsl_type *element_type = constructor_type->fields.array; in process_array_constructor()
1338 * spec quote above!) and attempt to convert the parameter to a constant in process_array_constructor()
1340 * parameters to the constructor are trivially constant valued in process_array_constructor()
1344 implicitly_convert_component(ir, element_type->base_type, state); in process_array_constructor()
1346 if (constructor_type->fields.array->is_unsized_array()) { in process_array_constructor()
1356 if (element_type->is_unsized_array()) { in process_array_constructor()
1358 element_type = ir->type; in process_array_constructor()
1359 } else if (element_type != ir->type) { in process_array_constructor()
1362 element_type->name, in process_array_constructor()
1363 ir->type->name); in process_array_constructor()
1366 } else if (ir->type != constructor_type->fields.array) { in process_array_constructor()
1369 constructor_type->fields.array->name, in process_array_constructor()
1370 ir->type->name); in process_array_constructor()
1373 element_type = ir->type; in process_array_constructor()
1377 if (constructor_type->fields.array->is_unsized_array()) { in process_array_constructor()
1382 assert(constructor_type->length == parameter_count); in process_array_constructor()
1390 instructions->push_tail(var); in process_array_constructor()
1398 instructions->push_tail(assignment); in process_array_constructor()
1408 * Determine if a list consists of a single scalar r-value
1413 const ir_rvalue *const p = (ir_rvalue *) parameters->get_head_raw(); in single_scalar_parameter()
1414 assert(((ir_rvalue *)p)->as_rvalue() != NULL); in single_scalar_parameter()
1416 return (p->type->is_scalar() && p->next->is_tail_sentinel()); in single_scalar_parameter()
1437 assert(!parameters->is_empty()); in emit_inline_vector_constructor()
1440 instructions->push_tail(var); in emit_inline_vector_constructor()
1444 * - Construct a vector from a single scalar by replicating that scalar to in emit_inline_vector_constructor()
1447 * - Construct a vector from at least a matrix. This case should already in emit_inline_vector_constructor()
1451 * - Construct a vector from an arbirary combination of vectors and in emit_inline_vector_constructor()
1455 const unsigned lhs_components = type->components(); in emit_inline_vector_constructor()
1457 ir_rvalue *first_param = (ir_rvalue *)parameters->get_head_raw(); in emit_inline_vector_constructor()
1461 const unsigned mask = (1U << lhs_components) - 1; in emit_inline_vector_constructor()
1463 assert(rhs->type == lhs->type); in emit_inline_vector_constructor()
1466 instructions->push_tail(inst); in emit_inline_vector_constructor()
1476 unsigned rhs_components = param->type->components(); in emit_inline_vector_constructor()
1480 rhs_components = lhs_components - base_lhs_component; in emit_inline_vector_constructor()
1483 const ir_constant *const c = param->as_constant(); in emit_inline_vector_constructor()
1486 switch (c->type->base_type) { in emit_inline_vector_constructor()
1488 data.u[i + base_component] = c->get_uint_component(i); in emit_inline_vector_constructor()
1491 data.i[i + base_component] = c->get_int_component(i); in emit_inline_vector_constructor()
1494 data.f[i + base_component] = c->get_float_component(i); in emit_inline_vector_constructor()
1497 data.d[i + base_component] = c->get_double_component(i); in emit_inline_vector_constructor()
1500 data.b[i + base_component] = c->get_bool_component(i); in emit_inline_vector_constructor()
1503 data.u64[i + base_component] = c->get_uint64_component(i); in emit_inline_vector_constructor()
1506 data.i64[i + base_component] = c->get_int64_component(i); in emit_inline_vector_constructor()
1515 constant_mask |= ((1U << rhs_components) - 1) << base_lhs_component; in emit_inline_vector_constructor()
1529 glsl_type::get_instance(var->type->base_type, in emit_inline_vector_constructor()
1536 instructions->push_tail(inst); in emit_inline_vector_constructor()
1541 unsigned rhs_components = param->type->components(); in emit_inline_vector_constructor()
1545 rhs_components = lhs_components - base_component; in emit_inline_vector_constructor()
1556 const ir_constant *const c = param->as_constant(); in emit_inline_vector_constructor()
1559 const unsigned write_mask = ((1U << rhs_components) - 1) in emit_inline_vector_constructor()
1570 instructions->push_tail(inst); in emit_inline_vector_constructor()
1604 assert(column_ref->type->components() >= (row_base + count)); in assign_to_matrix_column()
1605 assert(src->type->components() >= (src_base + count)); in assign_to_matrix_column()
1610 if (count < src->type->vector_elements) { in assign_to_matrix_column()
1618 const unsigned write_mask = ((1U << count) - 1) << row_base; in assign_to_matrix_column()
1641 assert(!parameters->is_empty()); in emit_inline_matrix_constructor()
1644 instructions->push_tail(var); in emit_inline_matrix_constructor()
1648 * - Construct a matrix from a single scalar by replicating that scalar to in emit_inline_matrix_constructor()
1652 * - Construct a matrix from an arbirary combination of vectors and in emit_inline_matrix_constructor()
1654 * to the matrix in column-major order until the matrix is full. in emit_inline_matrix_constructor()
1656 * - Construct a matrix from a single matrix. The source matrix is copied in emit_inline_matrix_constructor()
1660 ir_rvalue *const first_param = (ir_rvalue *) parameters->get_head_raw(); in emit_inline_matrix_constructor()
1665 glsl_base_type param_base_type = first_param->type->base_type; in emit_inline_matrix_constructor()
1666 assert(first_param->type->is_float() || first_param->type->is_double()); in emit_inline_matrix_constructor()
1671 instructions->push_tail(rhs_var); in emit_inline_matrix_constructor()
1675 if (first_param->type->is_float()) in emit_inline_matrix_constructor()
1682 new(ctx) ir_constant(rhs_var->type, &zero)); in emit_inline_matrix_constructor()
1683 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1689 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1704 const unsigned cols_to_init = MIN2(type->matrix_columns, in emit_inline_matrix_constructor()
1705 type->vector_elements); in emit_inline_matrix_constructor()
1713 type->vector_elements); in emit_inline_matrix_constructor()
1716 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1719 for (unsigned i = cols_to_init; i < type->matrix_columns; i++) { in emit_inline_matrix_constructor()
1726 type->vector_elements); in emit_inline_matrix_constructor()
1729 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1731 } else if (first_param->type->is_matrix()) { in emit_inline_matrix_constructor()
1741 assert(first_param->next->is_tail_sentinel()); in emit_inline_matrix_constructor()
1744 /* If the source matrix is smaller, pre-initialize the relavent parts of in emit_inline_matrix_constructor()
1747 if ((src_matrix->type->matrix_columns < var->type->matrix_columns) || in emit_inline_matrix_constructor()
1748 (src_matrix->type->vector_elements < var->type->vector_elements)) { in emit_inline_matrix_constructor()
1756 (src_matrix->type->vector_elements < var->type->vector_elements) in emit_inline_matrix_constructor()
1757 ? 0 : src_matrix->type->matrix_columns; in emit_inline_matrix_constructor()
1759 const glsl_type *const col_type = var->type->column_type(); in emit_inline_matrix_constructor()
1760 for (/* empty */; col < var->type->matrix_columns; col++) { in emit_inline_matrix_constructor()
1763 if (!col_type->is_double()) { in emit_inline_matrix_constructor()
1783 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1793 new(ctx) ir_variable(first_param->type, "mat_ctor_mat", in emit_inline_matrix_constructor()
1795 instructions->push_tail(rhs_var); in emit_inline_matrix_constructor()
1801 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1803 const unsigned last_row = MIN2(src_matrix->type->vector_elements, in emit_inline_matrix_constructor()
1804 var->type->vector_elements); in emit_inline_matrix_constructor()
1805 const unsigned last_col = MIN2(src_matrix->type->matrix_columns, in emit_inline_matrix_constructor()
1806 var->type->matrix_columns); in emit_inline_matrix_constructor()
1812 const unsigned write_mask = (1U << last_row) - 1; in emit_inline_matrix_constructor()
1830 if (lhs->type->vector_elements != rhs_col->type->vector_elements) { in emit_inline_matrix_constructor()
1838 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1841 const unsigned cols = type->matrix_columns; in emit_inline_matrix_constructor()
1842 const unsigned rows = type->vector_elements; in emit_inline_matrix_constructor()
1848 unsigned rhs_components = rhs->type->components(); in emit_inline_matrix_constructor()
1858 new(ctx) ir_variable(rhs->type, "mat_ctor_vec", ir_var_temporary); in emit_inline_matrix_constructor()
1859 instructions->push_tail(rhs_var); in emit_inline_matrix_constructor()
1864 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1873 unsigned count = MIN2(rows - row_idx, in emit_inline_matrix_constructor()
1874 rhs_components - rhs_base); in emit_inline_matrix_constructor()
1882 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1885 remaining_slots -= count; in emit_inline_matrix_constructor()
1914 instructions->push_tail(var); in emit_inline_record_constructor()
1916 exec_node *node = parameters->get_head_raw(); in emit_inline_record_constructor()
1917 for (unsigned i = 0; i < type->length; i++) { in emit_inline_record_constructor()
1918 assert(!node->is_tail_sentinel()); in emit_inline_record_constructor()
1921 new(mem_ctx) ir_dereference_record(d->clone(mem_ctx, NULL), in emit_inline_record_constructor()
1922 type->fields.structure[i].name); in emit_inline_record_constructor()
1924 ir_rvalue *const rhs = ((ir_instruction *) node)->as_rvalue(); in emit_inline_record_constructor()
1929 instructions->push_tail(assign); in emit_inline_record_constructor()
1930 node = node->next; in emit_inline_record_constructor()
1958 * "Implicit Conversions". In the latter case, an implicit conversion in process_record_constructor()
1967 if (parameter_count != constructor_type->length) { in process_record_constructor()
1970 parameter_count > constructor_type->length in process_record_constructor()
1972 constructor_type->name); in process_record_constructor()
1983 &constructor_type->fields.structure[i]; in process_record_constructor()
1986 * spec quote above!) and attempt to convert the parameter to a constant in process_record_constructor()
1988 * parameters to the constructor are trivially constant valued in process_record_constructor()
1992 implicitly_convert_component(ir, struct_field->type->base_type, in process_record_constructor()
1995 if (ir->type != struct_field->type) { in process_record_constructor()
1999 constructor_type->name, in process_record_constructor()
2000 struct_field->name, in process_record_constructor()
2001 ir->type->name, in process_record_constructor()
2002 struct_field->type->name); in process_record_constructor()
2025 /* Handle "method calls" in GLSL 1.20 - namely, array.length() */ in handle_method()
2027 state->check_version(120, 300, &loc, "methods not supported"); in handle_method()
2030 method = field->primary_expression.identifier; in handle_method()
2035 field->subexpressions[0]->set_is_lhs(true); in handle_method()
2036 op = field->subexpressions[0]->hir(instructions, state); in handle_method()
2038 if (!this->expressions.is_empty()) { in handle_method()
2043 if (op->type->is_array()) { in handle_method()
2044 if (op->type->is_unsized_array()) { in handle_method()
2045 if (!state->has_shader_storage_buffer_objects()) { in handle_method()
2051 } else if (op->variable_referenced()->is_in_shader_storage_block()) { in handle_method()
2052 /* Calculate length of an unsized array in run-time */ in handle_method()
2056 /* When actual size is known at link-time, this will be in handle_method()
2057 * replaced with a constant expression. in handle_method()
2063 result = new(ctx) ir_constant(op->type->array_size()); in handle_method()
2065 } else if (op->type->is_vector()) { in handle_method()
2066 if (state->has_420pack()) { in handle_method()
2068 result = new(ctx) ir_constant((int) op->type->vector_elements); in handle_method()
2074 } else if (op->type->is_matrix()) { in handle_method()
2075 if (state->has_420pack()) { in handle_method()
2077 result = new(ctx) ir_constant((int) op->type->matrix_columns); in handle_method()
2099 return type->is_numeric() || type->is_boolean() || in is_valid_constructor()
2100 (state->has_bindless() && (type->is_sampler() || type->is_image())); in is_valid_constructor()
2110 * 1. constructors - The first subexpression is an ast_type_specifier. in hir()
2111 * 2. methods - Only the .length() method of array types. in hir()
2112 * 3. functions - Calls to regular old functions. in hir()
2118 YYLTYPE loc = type->get_location(); in hir()
2121 const glsl_type *const constructor_type = type->glsl_type(& name, state); in hir()
2129 type->type_name); in hir()
2138 * "Samplers are represented using 64-bit integer handles, and may be " in hir()
2139 * converted to and from 64-bit integers using constructors." in hir()
2143 * "Images are represented using 64-bit integer handles, and may be in hir()
2144 * converted to and from 64-bit integers using constructors." in hir()
2146 if (constructor_type->contains_atomic() || in hir()
2147 (!state->has_bindless() && constructor_type->contains_opaque())) { in hir()
2149 state->has_bindless() ? "atomic" : "opaque", in hir()
2150 constructor_type->name); in hir()
2154 if (constructor_type->is_subroutine()) { in hir()
2157 constructor_type->name); in hir()
2161 if (constructor_type->is_array()) { in hir()
2162 if (!state->check_version(state->allow_glsl_120_subset_in_110 ? 110 : 120, in hir()
2168 & loc, &this->expressions, state); in hir()
2177 * Constructors for built-in language types, such as mat4 and vec2, are in hir()
2182 * When using the C-style initializer syntax from GLSL 4.20, constructors in hir()
2186 if (constructor_type->is_struct()) { in hir()
2188 &loc, &this->expressions, in hir()
2196 const unsigned type_components = constructor_type->components(); in hir()
2207 foreach_list_typed(ast_node, ast, link, &this->expressions) { in hir()
2208 ir_rvalue *result = ast->hir(instructions, state); in hir()
2218 constructor_type->name); in hir()
2222 if (!is_valid_constructor(result->type, state)) { in hir()
2224 "non-numeric data type", in hir()
2225 constructor_type->name); in hir()
2232 if (result->type->is_matrix()) in hir()
2238 components_used += result->type->components(); in hir()
2247 && constructor_type->is_matrix() in hir()
2248 && !state->check_version(120, 100, &loc, in hir()
2250 constructor_type->name)) { in hir()
2261 && constructor_type->is_matrix()) { in hir()
2264 constructor_type->name); in hir()
2278 constructor_type->name); in hir()
2286 if (!constructor_type->is_matrix()) { in hir()
2288 if (!matrix->type->is_matrix()) in hir()
2292 ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp", in hir()
2294 instructions->push_tail(var); in hir()
2295 instructions->push_tail( in hir()
2298 var->constant_value = matrix->constant_expression_value(ctx); in hir()
2301 for (int i = 0; i < matrix->type->matrix_columns; i++) { in hir()
2302 matrix->insert_before( in hir()
2306 matrix->remove(); in hir()
2323 * // pair of 32-bit unsigned integers in hir()
2324 * any sampler type(uvec2) // Converts a pair of 32-bit unsigned integers to in hir()
2327 * // pair of 32-bit unsigned integers in hir()
2328 * any image type(uvec2) // Converts a pair of 32-bit unsigned integers to in hir()
2331 if (ir->type->is_sampler() || ir->type->is_image()) { in hir()
2332 /* Convert a sampler/image type to a pair of 32-bit unsigned in hir()
2337 "be converted to a pair of 32-bit unsigned " in hir()
2341 } else if (constructor_type->is_sampler() || in hir()
2342 constructor_type->is_image()) { in hir()
2343 /* Convert a pair of 32-bit unsigned integers to a sampler or image in hir()
2346 if (ir->type != glsl_type::uvec2_type) { in hir()
2348 "be converted from a pair of 32-bit unsigned " in hir()
2354 glsl_type::get_instance(constructor_type->base_type, in hir()
2355 ir->type->vector_elements, in hir()
2356 ir->type->matrix_columns); in hir()
2361 /* Attempt to convert the parameter to a constant valued expression. in hir()
2363 * constructor are trivially constant valued expressions. in hir()
2365 ir_rvalue *const constant = result->constant_expression_value(ctx); in hir() local
2367 if (constant != NULL) in hir()
2368 result = constant; in hir()
2373 ir->replace_with(result); in hir()
2377 /* If all of the parameters are trivially constant, create a in hir()
2378 * constant representing the complete collection of parameters. in hir()
2382 } else if (constructor_type->is_scalar()) { in hir()
2386 } else if (constructor_type->is_vector()) { in hir()
2392 assert(constructor_type->is_matrix()); in hir()
2398 } else if (subexpressions[0]->oper == ast_field_selection) { in hir()
2408 process_parameters(instructions, &actual_parameters, &this->expressions, in hir()
2411 if (id->oper == ast_array_index) { in hir()
2413 id->subexpressions[0], in hir()
2414 id->subexpressions[1], &func_name, in hir()
2416 } else if (id->oper == ast_identifier) { in hir()
2417 func_name = id->primary_expression.identifier; in hir()
2441 this->expressions)) { in hir()
2444 } else if (sig->is_builtin() && strcmp(func_name, "ftransform") == 0) { in hir()
2446 * for remapping the variable references in the built-in shader. in hir()
2449 state->symbols->get_variable("gl_ModelViewProjectionMatrix"); in hir()
2450 ir_variable *vtx = state->symbols->get_variable("gl_Vertex"); in hir()
2457 if (sig->is_builtin() && in hir()
2458 state->stage == MESA_SHADER_FRAGMENT && in hir()
2459 state->ARB_fragment_shader_interlock_enable) { in hir()
2464 if (sig->is_builtin() && in hir()
2465 ((state->stage == MESA_SHADER_TESS_CTRL && in hir()
2468 if (state->current_function == NULL || in hir()
2469 strcmp(state->current_function->function_name(), "main") != 0) { in hir()
2474 if (state->found_return) { in hir()
2479 if (instructions != &state->current_function->body) { in hir()
2487 if (state->found_begin_interlock) in hir()
2490 state->found_begin_interlock = true; in hir()
2492 if (!state->found_begin_interlock) in hir()
2496 if (state->found_end_interlock) in hir()
2499 state->found_end_interlock = true; in hir()
2508 instructions->push_tail(tmp); in hir()
2522 foreach_list_typed(const ast_node, ast, link, &this->expressions) { in has_sequence_subexpression()
2523 if (ast->has_sequence_subexpression()) in has_sequence_subexpression()
2535 YYLTYPE loc = this->get_location(); in hir()
2537 if (!this->constructor_type) { in hir()
2538 _mesa_glsl_error(&loc, state, "type of C-style initializer unknown"); in hir()
2541 const glsl_type *const constructor_type = this->constructor_type; in hir()
2543 if (!state->has_420pack()) { in hir()
2544 _mesa_glsl_error(&loc, state, "C-style initialization requires the " in hir()
2549 if (constructor_type->is_array()) { in hir()
2551 &this->expressions, state); in hir()
2554 if (constructor_type->is_struct()) { in hir()
2556 &this->expressions, state); in hir()
2560 &this->expressions, state); in hir()