• Home
  • Raw
  • Download

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

51       ast->set_is_lhs(true);  in process_parameters()
52 ir_rvalue *result = ast->hir(instructions, state); in process_parameters()
56 actual_parameters->push_tail(ir_rvalue::error_value(mem_ctx)); in process_parameters()
61 ir_constant *const constant = in process_parameters() local
62 result->constant_expression_value(mem_ctx); in process_parameters()
64 if (constant != NULL) in process_parameters()
65 result = constant; in process_parameters()
67 actual_parameters->push_tail(result); in process_parameters()
102 glsl_get_type_name(param->ir_type == in prototype_string()
103 ir_type_variable ? ((ir_variable *)param)->type : in prototype_string()
104 ((ir_rvalue *)param)->type)); in prototype_string()
125 if (actual->data.memory_coherent && !formal->data.memory_coherent) { in verify_image_parameter()
128 "`coherent' qualifier", formal->name); in verify_image_parameter()
132 if (actual->data.memory_volatile && !formal->data.memory_volatile) { in verify_image_parameter()
135 "`volatile' qualifier", formal->name); in verify_image_parameter()
139 if (actual->data.memory_restrict && !formal->data.memory_restrict) { in verify_image_parameter()
142 "`restrict' qualifier", formal->name); in verify_image_parameter()
146 if (actual->data.memory_read_only && !formal->data.memory_read_only) { in verify_image_parameter()
149 "`readonly' qualifier", formal->name); in verify_image_parameter()
153 if (actual->data.memory_write_only && !formal->data.memory_write_only) { in verify_image_parameter()
156 "`writeonly' qualifier", formal->name); in verify_image_parameter()
168 (!var->is_in_shader_storage_block() && in verify_first_atomic_parameter()
169 var->data.mode != ir_var_shader_shared)) { in verify_first_atomic_parameter()
195 (var->data.image_format != PIPE_FORMAT_R32_UINT && in verify_atomic_image_parameter_qualifier()
196 var->data.image_format != PIPE_FORMAT_R32_SINT && in verify_atomic_image_parameter_qualifier()
197 var->data.image_format != PIPE_FORMAT_R32_FLOAT)) { in verify_atomic_image_parameter_qualifier()
235 foreach_in_list(const ir_variable, formal, &sig->parameters) { in verify_parameter_modes()
237 assert(!actual_ir_node->is_tail_sentinel()); in verify_parameter_modes()
238 assert(!actual_ast_node->is_tail_sentinel()); in verify_parameter_modes()
244 YYLTYPE loc = actual_ast->get_location(); in verify_parameter_modes()
247 if (formal->data.mode == ir_var_const_in && in verify_parameter_modes()
248 actual->ir_type != ir_type_constant) { in verify_parameter_modes()
250 "parameter `in %s' must be a constant expression", in verify_parameter_modes()
251 formal->name); in verify_parameter_modes()
256 if (formal->data.must_be_shader_input) { in verify_parameter_modes()
260 if (val->ir_type == ir_type_swizzle) { in verify_parameter_modes()
261 if (!state->is_version(440, 0)) { in verify_parameter_modes()
264 formal->name); in verify_parameter_modes()
267 val = ((ir_swizzle *)val)->val; in verify_parameter_modes()
271 if (val->ir_type == ir_type_dereference_array) { in verify_parameter_modes()
272 val = ((ir_dereference_array *)val)->array; in verify_parameter_modes()
273 } else if (val->ir_type == ir_type_dereference_record && in verify_parameter_modes()
274 !state->es_shader) { in verify_parameter_modes()
275 val = ((ir_dereference_record *)val)->record; in verify_parameter_modes()
281 if (const ir_dereference_variable *deref_var = val->as_dereference_variable()) in verify_parameter_modes()
282 var = deref_var->variable_referenced(); in verify_parameter_modes()
284 if (!var || var->data.mode != ir_var_shader_in) { in verify_parameter_modes()
287 formal->name); in verify_parameter_modes()
291 var->data.must_be_shader_input = 1; in verify_parameter_modes()
295 if (formal->data.mode == ir_var_function_out in verify_parameter_modes()
296 || formal->data.mode == ir_var_function_inout) { in verify_parameter_modes()
298 switch (formal->data.mode) { in verify_parameter_modes()
304 /* This AST-based check catches errors like f(i++). The IR-based in verify_parameter_modes()
306 * IR-level is just a temporary value, which is an l-value. in verify_parameter_modes()
308 if (actual_ast->non_lvalue_description != NULL) { in verify_parameter_modes()
311 mode, formal->name, in verify_parameter_modes()
312 actual_ast->non_lvalue_description); in verify_parameter_modes()
316 ir_variable *var = actual->variable_referenced(); in verify_parameter_modes()
318 if (var && formal->data.mode == ir_var_function_inout) { in verify_parameter_modes()
319 if ((var->data.mode == ir_var_auto || in verify_parameter_modes()
320 var->data.mode == ir_var_shader_out) && in verify_parameter_modes()
321 !var->data.assigned && in verify_parameter_modes()
322 !is_gl_identifier(var->name)) { in verify_parameter_modes()
324 var->name); in verify_parameter_modes()
329 var->data.assigned = true; in verify_parameter_modes()
331 if (var && var->data.read_only) { in verify_parameter_modes()
334 "read-only variable '%s'", in verify_parameter_modes()
335 mode, formal->name, in verify_parameter_modes()
336 actual->variable_referenced()->name); in verify_parameter_modes()
338 } else if (!actual->is_lvalue(state)) { in verify_parameter_modes()
341 mode, formal->name); in verify_parameter_modes()
345 assert(formal->data.mode == ir_var_function_in || in verify_parameter_modes()
346 formal->data.mode == ir_var_const_in); in verify_parameter_modes()
347 ir_variable *var = actual->variable_referenced(); in verify_parameter_modes()
349 if ((var->data.mode == ir_var_auto || in verify_parameter_modes()
350 var->data.mode == ir_var_shader_out) && in verify_parameter_modes()
351 !var->data.assigned && in verify_parameter_modes()
352 !is_gl_identifier(var->name)) { in verify_parameter_modes()
354 var->name); in verify_parameter_modes()
359 if (glsl_type_is_image(formal->type) && in verify_parameter_modes()
360 actual->variable_referenced()) { in verify_parameter_modes()
362 actual->variable_referenced())) in verify_parameter_modes()
366 actual_ir_node = actual_ir_node->next; in verify_parameter_modes()
367 actual_ast_node = actual_ast_node->next; in verify_parameter_modes()
371 const char *func_name = sig->function_name(); in verify_parameter_modes()
380 YYLTYPE loc = actual_ast->get_location(); in verify_parameter_modes()
383 actual->variable_referenced())) { in verify_parameter_modes()
393 YYLTYPE loc = actual_ast->get_location(); in verify_parameter_modes()
396 actual->variable_referenced())) { in verify_parameter_modes()
414 if (ir->ir_type == ir_type_dereference_array) { in copy_index_derefs_to_temps()
416 ir = a->array->as_dereference(); in copy_index_derefs_to_temps()
418 ir_rvalue *idx = a->array_index; in copy_index_derefs_to_temps()
419 ir_variable *var = idx->variable_referenced(); in copy_index_derefs_to_temps()
424 if (!var || var->data.read_only || var->data.memory_read_only) in copy_index_derefs_to_temps()
427 ir_variable *tmp = new(d->mem_ctx) ir_variable(idx->type, "idx_tmp", in copy_index_derefs_to_temps()
429 d->before_instructions->push_tail(tmp); in copy_index_derefs_to_temps()
432 new(d->mem_ctx) ir_dereference_variable(tmp); in copy_index_derefs_to_temps()
434 new(d->mem_ctx) ir_assignment(deref_tmp_1, in copy_index_derefs_to_temps()
435 idx->clone(d->mem_ctx, NULL)); in copy_index_derefs_to_temps()
436 d->before_instructions->push_tail(assignment); in copy_index_derefs_to_temps()
440 new(d->mem_ctx) ir_dereference_variable(tmp); in copy_index_derefs_to_temps()
441 a->array_index = deref_tmp_2; in copy_index_derefs_to_temps()
450 ir_expression *const expr = actual->as_expression(); in fix_parameter()
452 /* If the types match exactly and the parameter is not a vector-extract, in fix_parameter()
455 if (formal_type == actual->type in fix_parameter()
456 && (expr == NULL || expr->operation != ir_binop_vector_extract) in fix_parameter()
457 && actual->as_dereference_variable()) in fix_parameter()
463 if (!actual->as_dereference_variable()) { in fix_parameter()
472 * hold the value before conversion, and then perform the conversion after in fix_parameter()
490 * additional conversion is needed in the post-call re-write. in fix_parameter()
495 before_instructions->push_tail(tmp); in fix_parameter()
498 * parameter to the new temporary. Note that no type conversion is allowed in fix_parameter()
502 /* Inout parameters should never require conversion, since that would in fix_parameter()
503 * require an implicit conversion to exist both to and from the formal in fix_parameter()
506 assert (actual->type == formal_type); in fix_parameter()
511 new(mem_ctx) ir_assignment(deref_tmp_1, actual->clone(mem_ctx, NULL)); in fix_parameter()
512 before_instructions->push_tail(assignment); in fix_parameter()
520 actual->replace_with(deref_tmp_2); in fix_parameter()
524 * type conversion applied. in fix_parameter()
527 if (actual->type != formal_type) in fix_parameter()
528 rhs = convert_component(rhs, actual->type); in fix_parameter()
531 if (expr != NULL && expr->operation == ir_binop_vector_extract) { in fix_parameter()
532 lhs = new(mem_ctx) ir_dereference_array(expr->operands[0]->clone(mem_ctx, in fix_parameter()
534 expr->operands[1]->clone(mem_ctx, in fix_parameter()
539 after_instructions->push_tail(assignment_2); in fix_parameter()
545 * For non-void functions, this returns a dereference of the temporary
559 /* Perform implicit conversion of arguments. For out parameters, we need in generate_call()
560 * to place them in a temporary variable and do the conversion after the in generate_call()
562 * the post-call conversions in a temporary exec_list, and emit them later. in generate_call()
564 foreach_two_lists(formal_node, &sig->parameters, in generate_call()
569 if (glsl_type_is_numeric(formal->type) || glsl_type_is_boolean(formal->type)) { in generate_call()
570 switch (formal->data.mode) { in generate_call()
574 = convert_component(actual, formal->type); in generate_call()
575 actual->replace_with(converted); in generate_call()
580 fix_parameter(ctx, actual, formal->type, in generate_call()
582 formal->data.mode == ir_var_function_inout); in generate_call()
600 * Section 4.3.3 (Constant Expressions) of the GLSL 1.20.8 spec says: in generate_call()
602 * "A constant expression is one of in generate_call()
606 * - a built-in function call whose arguments are all constant in generate_call()
608 * functions, the noise functions, and ftransform. The built-in in generate_call()
610 * inside an initializer with an argument that is a constant in generate_call()
613 * Section 5.10 (Constant Expressions) of the GLSL ES 1.00.17 spec says: in generate_call()
615 * "A constant expression is one of in generate_call()
619 * - a built-in function call whose arguments are all constant in generate_call()
623 * Section 4.3.3 (Constant Expressions) of the GLSL ES 3.00.4 spec says: in generate_call()
625 * "A constant expression is one of in generate_call()
629 * - a built-in function call whose arguments are all constant in generate_call()
631 * functions. The built-in functions dFdx, dFdy, and fwidth must in generate_call()
633 * that is a constant expression." in generate_call()
635 * If the function call is a constant expression, don't generate any in generate_call()
638 if (state->is_version(120, 100) || in generate_call()
639 state->consts->AllowGLSLBuiltinConstantExpression) { in generate_call()
640 ir_constant *value = sig->constant_expression_value(ctx, in generate_call()
649 if (!glsl_type_is_void(sig->return_type)) { in generate_call()
652 ? ralloc_asprintf(ctx, "%s_retval", sig->function_name()) in generate_call()
657 var = new(ctx) ir_variable(sig->return_type, name, ir_var_temporary); in generate_call()
658 var->data.precision = sig->return_precision; in generate_call()
659 instructions->push_tail(var); in generate_call()
668 instructions->push_tail(call); in generate_call()
670 /* Also emit any necessary out-parameter conversions. */ in generate_call()
671 instructions->append_list(&post_call_conversions); in generate_call()
673 return deref ? deref->clone(ctx, NULL) : NULL; in generate_call()
684 ir_function *f = state->symbols->get_function(name); in match_function_by_name()
689 if (state->symbols->get_type(name)) in match_function_by_name()
693 if (!state->symbols->separate_function_namespace in match_function_by_name()
694 && state->symbols->get_variable(name)) in match_function_by_name()
698 /* In desktop GL, the presence of a user-defined signature hides any in match_function_by_name()
699 * built-in signatures, so we must ignore them. In contrast, in ES2 in match_function_by_name()
700 * user-defined signatures add new overloads, so we must consider them. in match_function_by_name()
702 bool allow_builtins = state->es_shader || !f->has_user_signature(); in match_function_by_name()
706 sig = local_sig = f->matching_signature(state, actual_parameters, in match_function_by_name()
707 state->has_implicit_conversions(), in match_function_by_name()
708 state->has_implicit_int_to_uint_conversion(), in match_function_by_name()
717 /* Local shader has no exact candidates; check the built-ins. */ in match_function_by_name()
742 _mesa_shader_stage_to_subroutine_prefix(state->stage), in match_subroutine_by_name()
744 var = state->symbols->get_variable(new_name); in match_subroutine_by_name()
748 for (int i = 0; i < state->num_subroutine_types; i++) { in match_subroutine_by_name()
749 f = state->subroutine_types[i]; in match_subroutine_by_name()
750 if (strcmp(f->name, glsl_get_type_name(glsl_without_array(var->type)))) in match_subroutine_by_name()
759 sig = found->matching_signature(state, actual_parameters, in match_subroutine_by_name()
760 state->has_implicit_conversions(), in match_subroutine_by_name()
761 state->has_implicit_int_to_uint_conversion(), in match_subroutine_by_name()
772 if (array->oper == ast_array_index) { in generate_array_index()
776 array->subexpressions[0], in generate_array_index()
777 array->subexpressions[1], in generate_array_index()
780 ir_rvalue *outer_array_idx = idx->hir(instructions, state); in generate_array_index()
782 YYLTYPE index_loc = idx->get_location(); in generate_array_index()
788 *function_name = array->primary_expression.identifier; in generate_array_index()
798 ir_rvalue *outer_array_idx = idx->hir(instructions, state); in generate_array_index()
807 ir_function *f = symbols->get_function(name); in function_exists()
809 foreach_in_list(ir_function_signature, sig, &f->signatures) { in function_exists()
810 if (sig->is_builtin() && !sig->is_builtin_available(state)) in function_exists()
825 foreach_in_list(ir_function_signature, sig, &f->signatures) { in print_function_prototypes()
826 if (sig->is_builtin() && !sig->is_builtin_available(state)) in print_function_prototypes()
829 char *str = prototype_string(sig->return_type, f->name, in print_function_prototypes()
830 &sig->parameters); in print_function_prototypes()
848 if (!function_exists(state, state->symbols, name) in no_matching_function_error()
849 && (!state->uses_builtin_functions in no_matching_function_error()
861 state->symbols->get_function(name)); in no_matching_function_error()
863 if (state->uses_builtin_functions) { in no_matching_function_error()
864 print_function_prototypes(state, loc, symb->get_function(name)); in no_matching_function_error()
870 * Perform automatic type conversion of constructor parameters
872 * This implements the rules in the "Conversion and Scalar Constructors"
879 const unsigned a = desired_type->base_type; in convert_component()
880 const unsigned b = src->type->base_type; in convert_component()
883 if (glsl_type_is_error(src->type)) in convert_component()
1128 assert(result->type == desired_type); in convert_component()
1130 /* Try constant folding; it may fold in the conversion we just added. */ in convert_component()
1131 ir_constant *const constant = result->constant_expression_value(ctx); in convert_component() local
1132 return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; in convert_component()
1137 * Perform automatic type and constant conversion of constructor parameters
1140 * "Conversion and Scalar Constructors".
1142 * After attempting the implicit conversion, an attempt to convert into a
1143 * constant valued expression is also done.
1152 * If the attempt to convert into a constant expression succeeds, \c true is
1162 if (to != from->type->base_type) { in implicitly_convert_component()
1165 from->type->vector_elements, in implicitly_convert_component()
1166 from->type->matrix_columns); in implicitly_convert_component()
1168 if (_mesa_glsl_can_implicitly_convert(from->type, desired_type, in implicitly_convert_component()
1169 state->has_implicit_conversions(), in implicitly_convert_component()
1170 state->has_implicit_int_to_uint_conversion())) { in implicitly_convert_component()
1172 * conversion rules (not the implicit conversion rules), its safe in implicitly_convert_component()
1174 * conversion is legal. in implicitly_convert_component()
1180 ir_rvalue *const constant = result->constant_expression_value(mem_ctx); in implicitly_convert_component() local
1182 if (constant != NULL) in implicitly_convert_component()
1183 result = constant; in implicitly_convert_component()
1186 from->replace_with(result); in implicitly_convert_component()
1190 return constant != NULL; in implicitly_convert_component()
1201 assert(component < glsl_get_components(src->type)); in dereference_component()
1203 /* If the source is a constant, just create a new constant instead of a in dereference_component()
1204 * dereference of the existing constant. in dereference_component()
1206 ir_constant *constant = src->as_constant(); in dereference_component() local
1207 if (constant) in dereference_component()
1208 return new(ctx) ir_constant(constant, component); in dereference_component()
1210 if (glsl_type_is_scalar(src->type)) { in dereference_component()
1212 } else if (glsl_type_is_vector(src->type)) { in dereference_component()
1215 assert(glsl_type_is_matrix(src->type)); in dereference_component()
1220 const int c = component / glsl_get_column_type(src->type)->vector_elements; in dereference_component()
1221 const int r = component % glsl_get_column_type(src->type)->vector_elements; in dereference_component()
1226 col->type = glsl_get_column_type(src->type); in dereference_component()
1252 if (constructor_type->vector_elements <= 1) { in process_vec_mat_constructor()
1264 constructor_type->vector_elements != parameter_count) in process_vec_mat_constructor()
1266 constructor_type->matrix_columns != parameter_count)) { in process_vec_mat_constructor()
1269 constructor_type->vector_elements); in process_vec_mat_constructor()
1278 * spec quote above!) and attempt to convert the parameter to a constant in process_vec_mat_constructor()
1280 * parameters to the constructor are trivially constant valued in process_vec_mat_constructor()
1284 implicitly_convert_component(ir, constructor_type->base_type, state); in process_vec_mat_constructor()
1287 if (ir->type != glsl_get_column_type(constructor_type)) { in process_vec_mat_constructor()
1291 glsl_get_type_name(ir->type)); in process_vec_mat_constructor()
1294 } else if (ir->type != glsl_get_scalar_type(constructor_type)) { in process_vec_mat_constructor()
1298 glsl_get_type_name(ir->type)); in process_vec_mat_constructor()
1308 instructions->push_tail(var); in process_vec_mat_constructor()
1315 if (glsl_type_is_matrix(var->type)) { in process_vec_mat_constructor()
1321 assert(glsl_type_is_vector(var->type)); in process_vec_mat_constructor()
1327 instructions->push_tail(assignment); in process_vec_mat_constructor()
1369 (!is_unsized_array && (constructor_type->length != parameter_count))) { in process_array_constructor()
1371 ? 1 : constructor_type->length; in process_array_constructor()
1382 glsl_array_type(constructor_type->fields.array, in process_array_constructor()
1385 assert(constructor_type->length == parameter_count); in process_array_constructor()
1389 const glsl_type *element_type = constructor_type->fields.array; in process_array_constructor()
1394 * spec quote above!) and attempt to convert the parameter to a constant in process_array_constructor()
1396 * parameters to the constructor are trivially constant valued in process_array_constructor()
1400 implicitly_convert_component(ir, element_type->base_type, state); in process_array_constructor()
1402 if (glsl_type_is_unsized_array(constructor_type->fields.array)) { in process_array_constructor()
1414 element_type = ir->type; in process_array_constructor()
1415 } else if (element_type != ir->type) { in process_array_constructor()
1419 glsl_get_type_name(ir->type)); in process_array_constructor()
1422 } else if (ir->type != constructor_type->fields.array) { in process_array_constructor()
1425 glsl_get_type_name(constructor_type->fields.array), in process_array_constructor()
1426 glsl_get_type_name(ir->type)); in process_array_constructor()
1429 element_type = ir->type; in process_array_constructor()
1433 if (glsl_type_is_unsized_array(constructor_type->fields.array)) { in process_array_constructor()
1437 assert(constructor_type->length == parameter_count); in process_array_constructor()
1445 instructions->push_tail(var); in process_array_constructor()
1453 instructions->push_tail(assignment); in process_array_constructor()
1463 * Determine if a list consists of a single scalar r-value
1468 const ir_rvalue *const p = (ir_rvalue *) parameters->get_head_raw(); in single_scalar_parameter()
1469 assert(((ir_rvalue *)p)->as_rvalue() != NULL); in single_scalar_parameter()
1471 return (glsl_type_is_scalar(p->type) && p->next->is_tail_sentinel()); in single_scalar_parameter()
1492 assert(!parameters->is_empty()); in emit_inline_vector_constructor()
1495 instructions->push_tail(var); in emit_inline_vector_constructor()
1499 * - Construct a vector from a single scalar by replicating that scalar to in emit_inline_vector_constructor()
1502 * - Construct a vector from at least a matrix. This case should already in emit_inline_vector_constructor()
1506 * - Construct a vector from an arbirary combination of vectors and in emit_inline_vector_constructor()
1512 ir_rvalue *first_param = (ir_rvalue *)parameters->get_head_raw(); in emit_inline_vector_constructor()
1523 unsigned rhs_components = glsl_get_components(param->type); in emit_inline_vector_constructor()
1527 rhs_components = lhs_components - base_lhs_component; in emit_inline_vector_constructor()
1530 const ir_constant *const c = param->as_constant(); in emit_inline_vector_constructor()
1533 switch (c->type->base_type) { in emit_inline_vector_constructor()
1535 data.u[i + base_component] = c->get_uint_component(i); in emit_inline_vector_constructor()
1538 data.i[i + base_component] = c->get_int_component(i); in emit_inline_vector_constructor()
1541 data.f[i + base_component] = c->get_float_component(i); in emit_inline_vector_constructor()
1544 data.d[i + base_component] = c->get_double_component(i); in emit_inline_vector_constructor()
1547 data.b[i + base_component] = c->get_bool_component(i); in emit_inline_vector_constructor()
1550 data.u64[i + base_component] = c->get_uint64_component(i); in emit_inline_vector_constructor()
1553 data.i64[i + base_component] = c->get_int64_component(i); in emit_inline_vector_constructor()
1562 constant_mask |= ((1U << rhs_components) - 1) << base_lhs_component; in emit_inline_vector_constructor()
1576 glsl_simple_type(var->type->base_type, constant_components, 1); in emit_inline_vector_constructor()
1581 instructions->push_tail(inst); in emit_inline_vector_constructor()
1586 unsigned rhs_components = glsl_get_components(param->type); in emit_inline_vector_constructor()
1590 rhs_components = lhs_components - base_component; in emit_inline_vector_constructor()
1601 const ir_constant *const c = param->as_constant(); in emit_inline_vector_constructor()
1604 const unsigned write_mask = ((1U << rhs_components) - 1) in emit_inline_vector_constructor()
1615 instructions->push_tail(inst); in emit_inline_vector_constructor()
1649 assert(glsl_get_components(column_ref->type) >= (row_base + count)); in assign_to_matrix_column()
1650 assert(glsl_get_components(src->type) >= (src_base + count)); in assign_to_matrix_column()
1655 if (count < src->type->vector_elements) { in assign_to_matrix_column()
1663 const unsigned write_mask = ((1U << count) - 1) << row_base; in assign_to_matrix_column()
1686 assert(!parameters->is_empty()); in emit_inline_matrix_constructor()
1689 instructions->push_tail(var); in emit_inline_matrix_constructor()
1693 * - Construct a matrix from a single scalar by replicating that scalar to in emit_inline_matrix_constructor()
1697 * - Construct a matrix from an arbirary combination of vectors and in emit_inline_matrix_constructor()
1699 * to the matrix in column-major order until the matrix is full. in emit_inline_matrix_constructor()
1701 * - Construct a matrix from a single matrix. The source matrix is copied in emit_inline_matrix_constructor()
1705 ir_rvalue *const first_param = (ir_rvalue *) parameters->get_head_raw(); in emit_inline_matrix_constructor()
1710 glsl_base_type param_base_type = first_param->type->base_type; in emit_inline_matrix_constructor()
1711 assert(glsl_type_is_float_16_32_64(first_param->type)); in emit_inline_matrix_constructor()
1716 instructions->push_tail(rhs_var); in emit_inline_matrix_constructor()
1720 if (glsl_type_is_float(first_param->type)) in emit_inline_matrix_constructor()
1727 new(ctx) ir_constant(rhs_var->type, &zero)); in emit_inline_matrix_constructor()
1728 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1734 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1749 const unsigned cols_to_init = MIN2(type->matrix_columns, in emit_inline_matrix_constructor()
1750 type->vector_elements); in emit_inline_matrix_constructor()
1758 type->vector_elements); in emit_inline_matrix_constructor()
1761 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1764 for (unsigned i = cols_to_init; i < type->matrix_columns; i++) { in emit_inline_matrix_constructor()
1771 type->vector_elements); in emit_inline_matrix_constructor()
1774 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1776 } else if (glsl_type_is_matrix(first_param->type)) { in emit_inline_matrix_constructor()
1786 assert(first_param->next->is_tail_sentinel()); in emit_inline_matrix_constructor()
1789 /* If the source matrix is smaller, pre-initialize the relavent parts of in emit_inline_matrix_constructor()
1792 if ((src_matrix->type->matrix_columns < var->type->matrix_columns) || in emit_inline_matrix_constructor()
1793 (src_matrix->type->vector_elements < var->type->vector_elements)) { in emit_inline_matrix_constructor()
1801 (src_matrix->type->vector_elements < var->type->vector_elements) in emit_inline_matrix_constructor()
1802 ? 0 : src_matrix->type->matrix_columns; in emit_inline_matrix_constructor()
1804 const glsl_type *const col_type = glsl_get_column_type(var->type); in emit_inline_matrix_constructor()
1805 for (/* empty */; col < var->type->matrix_columns; col++) { in emit_inline_matrix_constructor()
1828 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1838 new(ctx) ir_variable(first_param->type, "mat_ctor_mat", in emit_inline_matrix_constructor()
1840 instructions->push_tail(rhs_var); in emit_inline_matrix_constructor()
1846 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1848 const unsigned last_row = MIN2(src_matrix->type->vector_elements, in emit_inline_matrix_constructor()
1849 var->type->vector_elements); in emit_inline_matrix_constructor()
1850 const unsigned last_col = MIN2(src_matrix->type->matrix_columns, in emit_inline_matrix_constructor()
1851 var->type->matrix_columns); in emit_inline_matrix_constructor()
1857 const unsigned write_mask = (1U << last_row) - 1; in emit_inline_matrix_constructor()
1875 if (lhs->type->vector_elements != rhs_col->type->vector_elements) { in emit_inline_matrix_constructor()
1883 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1886 const unsigned cols = type->matrix_columns; in emit_inline_matrix_constructor()
1887 const unsigned rows = type->vector_elements; in emit_inline_matrix_constructor()
1893 unsigned rhs_components = glsl_get_components(rhs->type); in emit_inline_matrix_constructor()
1903 new(ctx) ir_variable(rhs->type, "mat_ctor_vec", ir_var_temporary); in emit_inline_matrix_constructor()
1904 instructions->push_tail(rhs_var); in emit_inline_matrix_constructor()
1909 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1918 unsigned count = MIN2(rows - row_idx, in emit_inline_matrix_constructor()
1919 rhs_components - rhs_base); in emit_inline_matrix_constructor()
1927 instructions->push_tail(inst); in emit_inline_matrix_constructor()
1930 remaining_slots -= count; in emit_inline_matrix_constructor()
1959 instructions->push_tail(var); in emit_inline_record_constructor()
1961 exec_node *node = parameters->get_head_raw(); in emit_inline_record_constructor()
1962 for (unsigned i = 0; i < type->length; i++) { in emit_inline_record_constructor()
1963 assert(!node->is_tail_sentinel()); in emit_inline_record_constructor()
1966 new(mem_ctx) ir_dereference_record(d->clone(mem_ctx, NULL), in emit_inline_record_constructor()
1967 type->fields.structure[i].name); in emit_inline_record_constructor()
1969 ir_rvalue *const rhs = ((ir_instruction *) node)->as_rvalue(); in emit_inline_record_constructor()
1974 instructions->push_tail(assign); in emit_inline_record_constructor()
1975 node = node->next; in emit_inline_record_constructor()
2003 * "Implicit Conversions". In the latter case, an implicit conversion in process_record_constructor()
2012 if (parameter_count != constructor_type->length) { in process_record_constructor()
2015 parameter_count > constructor_type->length in process_record_constructor()
2028 &constructor_type->fields.structure[i]; in process_record_constructor()
2031 * spec quote above!) and attempt to convert the parameter to a constant in process_record_constructor()
2033 * parameters to the constructor are trivially constant valued in process_record_constructor()
2037 implicitly_convert_component(ir, struct_field->type->base_type, in process_record_constructor()
2040 if (ir->type != struct_field->type) { in process_record_constructor()
2045 struct_field->name, in process_record_constructor()
2046 glsl_get_type_name(ir->type), in process_record_constructor()
2047 glsl_get_type_name(struct_field->type)); in process_record_constructor()
2070 /* Handle "method calls" in GLSL 1.20 - namely, array.length() */ in handle_method()
2072 state->check_version(120, 300, &loc, "methods not supported"); in handle_method()
2075 method = field->primary_expression.identifier; in handle_method()
2080 field->subexpressions[0]->set_is_lhs(true); in handle_method()
2081 op = field->subexpressions[0]->hir(instructions, state); in handle_method()
2083 if (!this->expressions.is_empty()) { in handle_method()
2088 if (glsl_type_is_array(op->type)) { in handle_method()
2089 if (glsl_type_is_unsized_array(op->type)) { in handle_method()
2090 if (!state->has_shader_storage_buffer_objects()) { in handle_method()
2096 } else if (op->variable_referenced()->is_in_shader_storage_block()) { in handle_method()
2097 /* Calculate length of an unsized array in run-time */ in handle_method()
2101 /* When actual size is known at link-time, this will be in handle_method()
2102 * replaced with a constant expression. in handle_method()
2108 result = new(ctx) ir_constant(glsl_array_size(op->type)); in handle_method()
2110 } else if (glsl_type_is_vector(op->type)) { in handle_method()
2111 if (state->has_420pack()) { in handle_method()
2113 result = new(ctx) ir_constant((int) op->type->vector_elements); in handle_method()
2119 } else if (glsl_type_is_matrix(op->type)) { in handle_method()
2120 if (state->has_420pack()) { in handle_method()
2122 result = new(ctx) ir_constant((int) op->type->matrix_columns); in handle_method()
2145 (state->has_bindless() && (glsl_type_is_sampler(type) || glsl_type_is_image(type))); in is_valid_constructor()
2155 * 1. constructors - The first subexpression is an ast_type_specifier. in hir()
2156 * 2. methods - Only the .length() method of array types. in hir()
2157 * 3. functions - Calls to regular old functions. in hir()
2163 YYLTYPE loc = type->get_location(); in hir()
2166 const glsl_type *const constructor_type = type->glsl_type(& name, state); in hir()
2174 type->type_name); in hir()
2183 * "Samplers are represented using 64-bit integer handles, and may be " in hir()
2184 * converted to and from 64-bit integers using constructors." in hir()
2188 * "Images are represented using 64-bit integer handles, and may be in hir()
2189 * converted to and from 64-bit integers using constructors." in hir()
2192 (!state->has_bindless() && glsl_contains_opaque(constructor_type))) { in hir()
2194 state->has_bindless() ? "atomic" : "opaque", in hir()
2207 if (!state->check_version(state->allow_glsl_120_subset_in_110 ? 110 : 120, in hir()
2213 & loc, &this->expressions, state); in hir()
2222 * Constructors for built-in language types, such as mat4 and vec2, are in hir()
2227 * When using the C-style initializer syntax from GLSL 4.20, constructors in hir()
2233 &loc, &this->expressions, in hir()
2252 foreach_list_typed(ast_node, ast, link, &this->expressions) { in hir()
2253 ir_rvalue *result = ast->hir(instructions, state); in hir()
2267 if (!is_valid_constructor(result->type, state)) { in hir()
2269 "non-numeric data type", in hir()
2277 if (glsl_type_is_matrix(result->type)) in hir()
2283 components_used += glsl_get_components(result->type); in hir()
2293 && !state->check_version(120, 100, &loc, in hir()
2333 if (!glsl_type_is_matrix(matrix->type)) in hir()
2337 ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp", in hir()
2339 instructions->push_tail(var); in hir()
2340 instructions->push_tail( in hir()
2343 var->constant_value = matrix->constant_expression_value(ctx); in hir()
2346 for (int i = 0; i < matrix->type->matrix_columns; i++) { in hir()
2347 matrix->insert_before( in hir()
2351 matrix->remove(); in hir()
2368 * // pair of 32-bit unsigned integers in hir()
2369 * any sampler type(uvec2) // Converts a pair of 32-bit unsigned integers to in hir()
2372 * // pair of 32-bit unsigned integers in hir()
2373 * any image type(uvec2) // Converts a pair of 32-bit unsigned integers to in hir()
2376 if (glsl_type_is_sampler(ir->type) || glsl_type_is_image(ir->type)) { in hir()
2377 /* Convert a sampler/image type to a pair of 32-bit unsigned in hir()
2382 "be converted to a pair of 32-bit unsigned " in hir()
2388 /* Convert a pair of 32-bit unsigned integers to a sampler or image in hir()
2391 if (ir->type != &glsl_type_builtin_uvec2) { in hir()
2393 "be converted from a pair of 32-bit unsigned " in hir()
2399 glsl_simple_type(constructor_type->base_type, in hir()
2400 ir->type->vector_elements, in hir()
2401 ir->type->matrix_columns); in hir()
2411 if (result->as_expression() && in hir()
2412 result->as_expression()->operation == ir_unop_pack_sampler_2x32) { in hir()
2416 instructions->push_tail(var); in hir()
2420 instructions->push_tail(assignment); in hir()
2424 /* Attempt to convert the parameter to a constant valued expression. in hir()
2426 * constructor are trivially constant valued expressions. in hir()
2428 ir_rvalue *const constant = result->constant_expression_value(ctx); in hir() local
2430 if (constant != NULL) in hir()
2431 result = constant; in hir()
2436 ir->replace_with(result); in hir()
2440 /* If all of the parameters are trivially constant, create a in hir()
2441 * constant representing the complete collection of parameters. in hir()
2461 } else if (subexpressions[0]->oper == ast_field_selection) { in hir()
2471 process_parameters(instructions, &actual_parameters, &this->expressions, in hir()
2474 if (id->oper == ast_array_index) { in hir()
2476 id->subexpressions[0], in hir()
2477 id->subexpressions[1], &func_name, in hir()
2479 } else if (id->oper == ast_identifier) { in hir()
2480 func_name = id->primary_expression.identifier; in hir()
2504 this->expressions)) { in hir()
2507 } else if (sig->is_builtin() && strcmp(func_name, "ftransform") == 0) { in hir()
2509 * for remapping the variable references in the built-in shader. in hir()
2512 state->symbols->get_variable("gl_ModelViewProjectionMatrix"); in hir()
2513 ir_variable *vtx = state->symbols->get_variable("gl_Vertex"); in hir()
2520 if (sig->is_builtin() && in hir()
2521 state->stage == MESA_SHADER_FRAGMENT && in hir()
2522 state->ARB_fragment_shader_interlock_enable) { in hir()
2527 if (sig->is_builtin() && in hir()
2528 ((state->stage == MESA_SHADER_TESS_CTRL && in hir()
2531 if (state->current_function == NULL || in hir()
2532 strcmp(state->current_function->function_name(), "main") != 0) { in hir()
2537 if (state->found_return) { in hir()
2542 if (instructions != &state->current_function->body) { in hir()
2550 if (state->found_begin_interlock) in hir()
2553 state->found_begin_interlock = true; in hir()
2555 if (!state->found_begin_interlock) in hir()
2559 if (state->found_end_interlock) in hir()
2562 state->found_end_interlock = true; in hir()
2571 instructions->push_tail(tmp); in hir()
2585 foreach_list_typed(const ast_node, ast, link, &this->expressions) { in has_sequence_subexpression()
2586 if (ast->has_sequence_subexpression()) in has_sequence_subexpression()
2598 YYLTYPE loc = this->get_location(); in hir()
2600 if (!this->constructor_type) { in hir()
2601 _mesa_glsl_error(&loc, state, "type of C-style initializer unknown"); in hir()
2604 const glsl_type *const constructor_type = this->constructor_type; in hir()
2606 if (!state->has_420pack()) { in hir()
2607 _mesa_glsl_error(&loc, state, "C-style initialization requires the " in hir()
2614 &this->expressions, state); in hir()
2619 &this->expressions, state); in hir()
2623 &this->expressions, state); in hir()