Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl.y:
+static bool intrinsic_sign(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
+{
- struct hlsl_ir_node *zero, *lt, *neg, *op1, *op2, *arg = params->args[0];
- struct hlsl_type *int_type = hlsl_get_numeric_type(ctx, arg->data_type->class, HLSL_TYPE_INT,
arg->data_type->dimx, arg->data_type->dimy);
- if (!(zero = hlsl_new_float_constant(ctx, 0.0f, loc)))
return false;
- list_add_tail(params->instrs, &zero->entry);
- /* Check if 0 < arg, cast bool to int */
- if (!(lt = add_binary_comparison_expr(ctx, params->instrs, HLSL_OP2_LESS, zero, arg, loc)))
This means that expressions of type other than `float` are casted to `float`. In principle that should be correct in the end, because AFAIU the sign should always be mapped correctly, but it makes me a bit nervous. Could the type of zero be set to coincide with the type of the argument?