Francisco Casas (@fcasas) commented about libs/vkd3d-shader/hlsl.y:
- return false; + static const char template[] = + "%s smoothstep_%s(%s low, %s high, %s x)\n" + "{\n" + " %s p = saturate((x - low) / (high - low));\n" + " return (p * p) * (3 - 2 * p);\n" + "}";
- if (!(p = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, p, p, loc))) + if (!(type = elementwise_intrinsic_get_common_type(ctx, params, loc))) return false; + type = hlsl_get_numeric_type(ctx, type->class, HLSL_TYPE_FLOAT, type->dimx, type->dimy);
- if (!(res = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, p, res, loc))) + name = hlsl_sprintf_alloc(ctx, "<internal>smoothstep_%s", type->name); + body = hlsl_sprintf_alloc(ctx, template, type->name, type->name, type->name, type->name, type->name, type->name); Should this account for the possibility of the hlsl_sprintf_alloc() calls returning NULL?
-- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/310#note_43630