Module: vkd3d
Branch: master
Commit: fef118555cd6341eb648f482a4517d61c347a0d3
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/fef118555cd6341eb648f482a4517…
Author: Zebediah Figura <zfigura(a)codeweavers.com>
Date: Fri Sep 8 16:44:55 2023 -0500
vkd3d-shader/hlsl: Do not prioritize an exact match when looking up functions.
Native does not always do this. For example, functions whose parameters are
float and float1 always result in an "ambiguous function call" error.
This does not fix any tests, because the relevant tests previously (incorrectly)
succeeded, and now fail with:
E5017: Aborting due to not yet implemented feature: Prioritize between multiple compatible function overloads.
when they should simply fail.
---
libs/vkd3d-shader/hlsl.y | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index baae591d..57c63c43 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -2325,21 +2325,6 @@ 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)
{
@@ -2370,9 +2355,6 @@ 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)
Module: vkd3d
Branch: master
Commit: b1c2852cd7228c89da41b1b443d2195ab1c55893
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/b1c2852cd7228c89da41b1b443d21…
Author: Zebediah Figura <zfigura(a)codeweavers.com>
Date: Fri Sep 8 16:27:10 2023 -0500
vkd3d-shader/hlsl: Store function overloads in a list.
The choice to store them in an rbtree was made early on. It does not seem likely
that HLSL programs would define many overloads for any of their functions, but I
suspect the idea was rather that intrinsics would be defined as plain
hlsl_ir_function_decl structures [cf. 447463e5900ca6a636998a65429b8a08a5441657]
and that some intrinsics that could operate on any type would therefore need
many overrides.
This is not how we deal with intrinsics, however. When the first intrinsics were
implemented I made the choice disregard this intended design, and instead match
and convert their types manually, in C. Nothing that has happened in the time
since has led me to question that choice, and in fact, the flexibility with
which we must accommodate functions has led me to believe that matching in this
way was definitely the right choice. The main other designs I see would have
been:
* define each intrinsic variant separately using existing HLSL types. Besides
efficiency concerns (i.e. this would take more space in memory, and would take
longer to generate each variant), the normal type-matching rules don't really
apply to intrinsics.
[For example: elementwise intrinsics like abs() return the same type as the
input, including preserving the distinction between float and float1. It is
legal to define separate HLSL overloads taking float and float1, but trying to
invoke these functions yields an "ambiguous function call" error.]
* introduce new (semi-)generic types. This is far more code and ends up acting
like our current scheme (with helpers) in a slightly more complex form.
So I think we can go ahead and rip out this vestige of the original design for
intrinsics.
As for why to change it: rbtrees are simply more complex to deal with, and it
seems unlikely to me that the difference is going to matter. I do not expect any
program to define large quantities of intrinsics; linked list search should be
good enough.
---
libs/vkd3d-shader/hlsl.c | 47 ++++++++++++++---------
libs/vkd3d-shader/hlsl.h | 8 ++--
libs/vkd3d-shader/hlsl.y | 81 ++++++++++++++--------------------------
libs/vkd3d-shader/hlsl_codegen.c | 16 +++-----
4 files changed, 69 insertions(+), 83 deletions(-)