Francisco Casas (@fcasas) commented about libs/vkd3d-shader/hlsl.y:
- hlsl_block_add_instr(params->instrs, minus_two);
- if (!(three = hlsl_new_float_constant(ctx, 3.0, loc)))
return false;
- hlsl_block_add_instr(params->instrs, three);
- if (!(res = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, minus_two, p, loc)))
return false;
- struct hlsl_ir_function_decl *func;
- struct hlsl_type *type;
- char *name, *body;
- if (!(res = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, three, res, loc)))
return false;
- static const char template[] =
"%s smoothstep_%s(%s low, %s high, %s x)\n"
Do we need to manually define the internal function with a new name for each overload?
I see that this is currently the case because hlsl_compile_internal_function() uses hlsl_get_func_decl() internally.
But, since we are compiling the function once for each call to the intrinsic anyways, what if we change hlsl_compile_internal_function() slightly so that it only expects the return type, the clean name of the function (e.g. just "smoothstep") and the body without the signature?
This so that only hlsl_compile_internal_function() has to care about the real internal name of the compiled function, maybe using an internal counter to give them a unique name e.g. `<internal-42>smoothstep`. That way we don't have to care about overloads.