mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Prefer overload candidates with matching component types.
This commit is contained in:
parent
6b8878377f
commit
32d432ab5e
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
@ -3023,6 +3023,7 @@ static int function_parameter_compare(const struct hlsl_ir_var *candidate,
|
|||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
enum hlsl_base_type type;
|
||||||
enum hlsl_base_type class;
|
enum hlsl_base_type class;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
} c, r, a;
|
} c, r, a;
|
||||||
@ -3032,13 +3033,16 @@ static int function_parameter_compare(const struct hlsl_ir_var *candidate,
|
|||||||
if (!hlsl_is_numeric_type(arg->data_type))
|
if (!hlsl_is_numeric_type(arg->data_type))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
c.class = hlsl_base_type_class(candidate->data_type->e.numeric.type);
|
c.type = candidate->data_type->e.numeric.type;
|
||||||
|
c.class = hlsl_base_type_class(c.type);
|
||||||
c.count = hlsl_type_component_count(candidate->data_type);
|
c.count = hlsl_type_component_count(candidate->data_type);
|
||||||
|
|
||||||
r.class = hlsl_base_type_class(ref->data_type->e.numeric.type);
|
r.type = ref->data_type->e.numeric.type;
|
||||||
|
r.class = hlsl_base_type_class(r.type);
|
||||||
r.count = hlsl_type_component_count(ref->data_type);
|
r.count = hlsl_type_component_count(ref->data_type);
|
||||||
|
|
||||||
a.class = hlsl_base_type_class(arg->data_type->e.numeric.type);
|
a.type = arg->data_type->e.numeric.type;
|
||||||
|
a.class = hlsl_base_type_class(a.type);
|
||||||
a.count = hlsl_type_component_count(arg->data_type);
|
a.count = hlsl_type_component_count(arg->data_type);
|
||||||
|
|
||||||
/* Prefer candidates without component count narrowing. E.g., given an
|
/* Prefer candidates without component count narrowing. E.g., given an
|
||||||
@ -3051,6 +3055,11 @@ static int function_parameter_compare(const struct hlsl_ir_var *candidate,
|
|||||||
if ((ret = (a.class == c.class) - (a.class == r.class)))
|
if ((ret = (a.class == c.class) - (a.class == r.class)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* Prefer candidates with matching component types. E.g., given an int
|
||||||
|
* argument, int4 is a better match than uint4. */
|
||||||
|
if ((ret = (a.type == c.type) - (a.type == r.type)))
|
||||||
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
/* Test a basic overload. */
|
/* Test a basic overload. */
|
||||||
float func(int arg)
|
float func(int arg)
|
||||||
{
|
{
|
||||||
@ -37,11 +37,11 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo(sm<6) draw quad
|
draw quad
|
||||||
probe (0, 0) rgba (0.1, 0.2, 0.1, 0.2)
|
probe (0, 0) rgba (0.1, 0.2, 0.1, 0.2)
|
||||||
|
|
||||||
|
|
||||||
[pixel shader fail]
|
[pixel shader fail todo]
|
||||||
float func(int arg)
|
float func(int arg)
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
@ -58,7 +58,7 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
float func(int arg)
|
float func(int arg)
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
@ -78,8 +78,8 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo(sm<6) draw quad
|
draw quad
|
||||||
todo(sm<6) probe (0,0) rgba (1.0, 2.0, 2.0, 2.0)
|
probe (0, 0) rgba(1.0, 2.0, 2.0, 2.0)
|
||||||
|
|
||||||
|
|
||||||
% float and float1 can be defined separately...
|
% float and float1 can be defined separately...
|
||||||
@ -307,7 +307,7 @@ probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
|||||||
% E.g. in the following example, C is "int" in both cases, but "int" <-> "uint"
|
% E.g. in the following example, C is "int" in both cases, but "int" <-> "uint"
|
||||||
% casts are preferred.
|
% casts are preferred.
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
|
|
||||||
float4 func(uint x)
|
float4 func(uint x)
|
||||||
{
|
{
|
||||||
@ -325,12 +325,12 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo(sm<6) draw quad
|
draw quad
|
||||||
todo(sm<6) probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
todo(sm<6) probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
||||||
|
|
||||||
% Same as above.
|
% Same as above.
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
|
|
||||||
float4 func(int x)
|
float4 func(int x)
|
||||||
{
|
{
|
||||||
@ -348,7 +348,7 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo(sm<6) draw quad
|
draw quad
|
||||||
todo(sm<6) probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
todo(sm<6) probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
||||||
|
|
||||||
% An exact match is preferred for minimum precision types as well.
|
% An exact match is preferred for minimum precision types as well.
|
||||||
@ -448,7 +448,7 @@ probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
|||||||
[require]
|
[require]
|
||||||
% Reset
|
% Reset
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
|
|
||||||
float4 func(float2 x)
|
float4 func(float2 x)
|
||||||
{
|
{
|
||||||
@ -466,8 +466,8 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo(sm<6) draw quad
|
draw quad
|
||||||
todo(sm<6) probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
|
||||||
|
|
||||||
% Some matrices are implicitly compatible with vectors and will ambiguate with them.
|
% Some matrices are implicitly compatible with vectors and will ambiguate with them.
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ float4 main() : sv_target
|
|||||||
return refract(r, n, i);
|
return refract(r, n, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
[pixel shader todo(sm<6)]
|
[pixel shader]
|
||||||
float4 r;
|
float4 r;
|
||||||
float4 n;
|
float4 n;
|
||||||
float i;
|
float i;
|
||||||
@ -228,6 +228,6 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo(sm<6) draw quad
|
draw quad
|
||||||
if(sm<6) probe (0,0) rgba (2.0, 1.0, 1.0, 1.0)
|
if(sm<6) probe (0,0) rgba (2.0, 1.0, 1.0, 1.0)
|
||||||
if(sm>=6) probe (0,0) rgba (1.0, 1.0, 1.0, 1.0)
|
if(sm>=6) probe (0,0) rgba (1.0, 1.0, 1.0, 1.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user