vkd3d-shader/hlsl: Prefer overload candidates without component count widening.

This commit is contained in:
Henri Verbeet 2024-12-10 22:56:44 +01:00
parent 64bb4150f0
commit c4f69f4d3d
Notes: Henri Verbeet 2024-12-16 17:26:51 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1313
2 changed files with 5 additions and 3 deletions

View File

@ -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,

View File

@ -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.