From: Francisco Casas fcasas@codeweavers.com
This reverts commit fef118555cd6341eb648f482a4517d61c347a0d3.
While it is true that overloads between "float1" and "float" retrieve an error in the native compiler, this is the exception rather than the general rule.
There are still many other cases of multiple compatible function overloads, such as the modified test, where the exact match should be prioritized instead of throwing an error, so this is better for applications. --- libs/vkd3d-shader/hlsl.y | 18 ++++++++++++++++++ tests/hlsl/function-overload.shader_test | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index fb6520bc6..b8956548d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2331,6 +2331,21 @@ static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var return initializers; }
+static bool func_is_exact_match(const struct hlsl_ir_function_decl *decl, const struct parse_initializer *args) +{ + unsigned int i; + + if (decl->parameters.count != args->args_count) + return false; + + for (i = 0; i < decl->parameters.count; ++i) + { + if (!hlsl_types_are_equal(decl->parameters.vars[i]->data_type, args->args[i]->data_type)) + return false; + } + return true; +} + static bool func_is_compatible_match(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *decl, const struct parse_initializer *args) { @@ -2361,6 +2376,9 @@ static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx,
LIST_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry) { + if (func_is_exact_match(decl, args)) + return decl; + if (func_is_compatible_match(ctx, decl, args)) { if (compatible_match) diff --git a/tests/hlsl/function-overload.shader_test b/tests/hlsl/function-overload.shader_test index 7b298ba30..121edf348 100644 --- a/tests/hlsl/function-overload.shader_test +++ b/tests/hlsl/function-overload.shader_test @@ -41,7 +41,7 @@ todo(sm<6) draw quad probe all rgba (0.1, 0.2, 0.1, 0.2)
-[pixel shader todo fail(sm>=6)] +[pixel shader fail(sm>=6)] float func(int arg) { return 1.0; @@ -58,7 +58,7 @@ float4 main() : sv_target }
[test] -todo(sm<6) draw quad +draw quad probe all rgba (2.0, 2.0, 1.0, 1.0)