mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Find compatible function overloads.
But still throw hlsl_fixme() when there is more than one. Prioritizing among multiple compatible function overloads in the same way as the native compiler would require systematic testing.
This commit is contained in:
parent
d279d34801
commit
f08c0a7c03
Notes:
Alexandre Julliard
2023-02-20 22:45:40 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/99
@ -2220,8 +2220,10 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
||||
|
||||
struct find_function_call_args
|
||||
{
|
||||
struct hlsl_ctx *ctx;
|
||||
const struct parse_initializer *params;
|
||||
struct hlsl_ir_function_decl *decl;
|
||||
unsigned int compatible_overloads_count;
|
||||
};
|
||||
|
||||
static void find_function_call_exact(struct rb_entry *entry, void *context)
|
||||
@ -2241,10 +2243,31 @@ static void find_function_call_exact(struct rb_entry *entry, void *context)
|
||||
args->decl = decl;
|
||||
}
|
||||
|
||||
static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx,
|
||||
const char *name, const struct parse_initializer *params)
|
||||
static void find_function_call_compatible(struct rb_entry *entry, void *context)
|
||||
{
|
||||
struct find_function_call_args args = {.params = params};
|
||||
struct hlsl_ir_function_decl *decl = RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry);
|
||||
struct find_function_call_args *args = context;
|
||||
unsigned int i;
|
||||
|
||||
if (decl->parameters.count != args->params->args_count)
|
||||
return;
|
||||
|
||||
for (i = 0; i < decl->parameters.count; ++i)
|
||||
{
|
||||
if (!implicit_compatible_data_types(args->ctx, args->params->args[i]->data_type,
|
||||
decl->parameters.vars[i]->data_type))
|
||||
return;
|
||||
}
|
||||
|
||||
args->compatible_overloads_count++;
|
||||
args->decl = decl;
|
||||
}
|
||||
|
||||
static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx,
|
||||
const char *name, const struct parse_initializer *params,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct find_function_call_args args = {.ctx = ctx, .params = params};
|
||||
struct hlsl_ir_function *func;
|
||||
struct rb_entry *entry;
|
||||
|
||||
@ -2254,7 +2277,13 @@ static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx,
|
||||
|
||||
rb_for_each_entry(&func->overloads, find_function_call_exact, &args);
|
||||
if (!args.decl)
|
||||
FIXME("Search for compatible overloads.\n");
|
||||
{
|
||||
rb_for_each_entry(&func->overloads, find_function_call_compatible, &args);
|
||||
if (args.compatible_overloads_count > 1)
|
||||
{
|
||||
hlsl_fixme(ctx, loc, "Prioritize between multiple compatible function overloads.");
|
||||
}
|
||||
}
|
||||
return args.decl;
|
||||
}
|
||||
|
||||
@ -3055,7 +3084,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
|
||||
struct intrinsic_function *intrinsic;
|
||||
struct hlsl_ir_function_decl *decl;
|
||||
|
||||
if ((decl = find_function_call(ctx, name, args)))
|
||||
if ((decl = find_function_call(ctx, name, args, loc)))
|
||||
{
|
||||
struct hlsl_ir_node *call;
|
||||
unsigned int i;
|
||||
@ -3069,8 +3098,12 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
|
||||
|
||||
if (!hlsl_types_are_equal(arg->data_type, param->data_type))
|
||||
{
|
||||
hlsl_fixme(ctx, &arg->loc, "Implicit cast of a function argument.");
|
||||
continue;
|
||||
struct hlsl_ir_node *cast;
|
||||
|
||||
if (!(cast = add_cast(ctx, args->instrs, arg, param->data_type, &arg->loc)))
|
||||
goto fail;
|
||||
args->args[i] = cast;
|
||||
arg = cast;
|
||||
}
|
||||
|
||||
if (param->storage_modifiers & HLSL_STORAGE_IN)
|
||||
|
@ -139,7 +139,7 @@ float4 main() : sv_target
|
||||
|
||||
|
||||
% Arrays with the same number of components are allowed.
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float fun(float a[2][3])
|
||||
{
|
||||
return 100*a[0][0] + 10*a[0][2] + a[1][2];
|
||||
@ -153,11 +153,11 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
todo probe all rgba (136.0, 136.0, 136.0, 136.0)
|
||||
draw quad
|
||||
probe all rgba (136.0, 136.0, 136.0, 136.0)
|
||||
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float fun(float a[2][3])
|
||||
{
|
||||
return 100*a[0][0] + 10*a[1][0] + a[1][2];
|
||||
@ -171,5 +171,5 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
todo probe all rgba (702.0, 702.0, 702.0, 702.0)
|
||||
draw quad
|
||||
probe all rgba (702.0, 702.0, 702.0, 702.0)
|
||||
|
@ -82,7 +82,7 @@ float4 PSMain() : SV_TARGET
|
||||
}
|
||||
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float4 fun(float3 f)
|
||||
{
|
||||
return f.xyxy;
|
||||
@ -94,5 +94,5 @@ float4 main() : SV_TARGET
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
todo probe all rgba (33.0, 33.0, 33.0, 33.0)
|
||||
draw quad
|
||||
probe all rgba (33.0, 33.0, 33.0, 33.0)
|
||||
|
@ -124,7 +124,7 @@ draw quad
|
||||
probe all rgba (4.0, 4.0, 4.0, 4.0)
|
||||
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
Texture2D tex;
|
||||
|
||||
struct apple
|
||||
@ -154,8 +154,8 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
todo probe all rgba (5.0, 5.0, 5.0, 5.0)
|
||||
draw quad
|
||||
probe all rgba (5.0, 5.0, 5.0, 5.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
|
@ -1,4 +1,4 @@
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
|
||||
float2 max(float2 a, float2 b)
|
||||
{
|
||||
@ -11,10 +11,10 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
probe all rgba (0.3, 0.3, 0.4, 0.6)
|
||||
draw quad
|
||||
todo probe all rgba (0.3, 0.3, 0.4, 0.6)
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
|
||||
float2 max(float2 a, float3 b)
|
||||
{
|
||||
@ -27,5 +27,5 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
draw quad
|
||||
probe all rgba (0.3, 0.3, 0.3, 0.4)
|
||||
|
Loading…
x
Reference in New Issue
Block a user