diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index f67dfdf5..a3814a81 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3088,7 +3088,9 @@ static int function_parameter_compare(const struct hlsl_ir_var *candidate, if ((ret = (a.width > r.width) - (a.width > c.width))) return ret; - return 0; + /* Prefer candidates without component count widening. E.g. given a float + * argument, float is a better match than float2. */ + return (a.count < r.count) - (a.count < c.count); } static int function_compare(const struct hlsl_ir_function_decl *candidate, diff --git a/tests/hlsl/function-overload.shader_test b/tests/hlsl/function-overload.shader_test index 5253181a..d252556d 100644 --- a/tests/hlsl/function-overload.shader_test +++ b/tests/hlsl/function-overload.shader_test @@ -184,7 +184,7 @@ float4 main() : sv_target } % An exact match is preferred over widening. -[pixel shader todo] +[pixel shader] float f(float x) { return 1.0; } float f(float2 x) { return 2.0; } @@ -194,7 +194,7 @@ float4 main() : sv_target } [test] -todo(sm<6) draw quad +draw quad probe (0, 0) rgba(1.0, 1.0, 1.0, 1.0) % Component type narrowing is preferred over component count narrowing.