Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wine
vkd3d
Commits
0a345a2b
Commit
0a345a2b
authored
2 years ago
by
Francisco Casas
Committed by
Alexandre Julliard
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Rename "t1" and "t2" arguments as "src" and "dst".
parent
963ea98a
No related branches found
No related tags found
1 merge request
!35
vkd3d-shader/hlsl: Support complex implicit casts, complex explicit casts and complex broadcasts. (PART 2/3 v2)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/vkd3d-shader/hlsl.y
+55
-55
55 additions, 55 deletions
libs/vkd3d-shader/hlsl.y
with
55 additions
and
55 deletions
libs/vkd3d-shader/hlsl.y
+
55
−
55
View file @
0a345a2b
...
...
@@ -153,121 +153,121 @@ static bool convertible_data_type(struct hlsl_type *type)
return type->type != HLSL_CLASS_OBJECT;
}
static bool compatible_data_types(struct hlsl_type *
t1
, struct hlsl_type *t
2
)
static bool compatible_data_types(struct hlsl_type *
src
, struct hlsl_type *
ds
t)
{
if (!convertible_data_type(
t1
) || !convertible_data_type(t
2
))
if (!convertible_data_type(
src
) || !convertible_data_type(
ds
t))
return false;
if (
t1
->type <= HLSL_CLASS_LAST_NUMERIC)
if (
src
->type <= HLSL_CLASS_LAST_NUMERIC)
{
/* Scalar vars can be cast to pretty much everything */
if (
t1
->dimx == 1 &&
t1
->dimy == 1)
if (
src
->dimx == 1 &&
src
->dimy == 1)
return true;
if (
t1
->type == HLSL_CLASS_VECTOR && t
2
->type == HLSL_CLASS_VECTOR)
return
t1
->dimx >= t
2
->dimx;
if (
src
->type == HLSL_CLASS_VECTOR &&
ds
t->type == HLSL_CLASS_VECTOR)
return
src
->dimx >=
ds
t->dimx;
}
/* The other way around is true too i.e. whatever to scalar */
if (t
2
->type <= HLSL_CLASS_LAST_NUMERIC && t
2
->dimx == 1 && t
2
->dimy == 1)
if (
ds
t->type <= HLSL_CLASS_LAST_NUMERIC &&
ds
t->dimx == 1 &&
ds
t->dimy == 1)
return true;
if (
t1
->type == HLSL_CLASS_ARRAY)
if (
src
->type == HLSL_CLASS_ARRAY)
{
if (hlsl_types_are_equal(
t1
->e.array.type, t
2
))
if (hlsl_types_are_equal(
src
->e.array.type,
ds
t))
/* e.g. float4[3] to float4 is allowed */
return true;
if (t
2
->type == HLSL_CLASS_ARRAY || t
2
->type == HLSL_CLASS_STRUCT)
return hlsl_type_component_count(
t1
) >= hlsl_type_component_count(t
2
);
if (
ds
t->type == HLSL_CLASS_ARRAY ||
ds
t->type == HLSL_CLASS_STRUCT)
return hlsl_type_component_count(
src
) >= hlsl_type_component_count(
ds
t);
else
return hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
);
return hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t);
}
if (
t1
->type == HLSL_CLASS_STRUCT)
return hlsl_type_component_count(
t1
) >= hlsl_type_component_count(t
2
);
if (
src
->type == HLSL_CLASS_STRUCT)
return hlsl_type_component_count(
src
) >= hlsl_type_component_count(
ds
t);
if (t
2
->type == HLSL_CLASS_ARRAY || t
2
->type == HLSL_CLASS_STRUCT)
return hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
);
if (
ds
t->type == HLSL_CLASS_ARRAY ||
ds
t->type == HLSL_CLASS_STRUCT)
return hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t);
if (
t1
->type == HLSL_CLASS_MATRIX || t
2
->type == HLSL_CLASS_MATRIX)
if (
src
->type == HLSL_CLASS_MATRIX ||
ds
t->type == HLSL_CLASS_MATRIX)
{
if (
t1
->type == HLSL_CLASS_MATRIX && t
2
->type == HLSL_CLASS_MATRIX &&
t1
->dimx >= t
2
->dimx &&
t1
->dimy >= t
2
->dimy)
if (
src
->type == HLSL_CLASS_MATRIX &&
ds
t->type == HLSL_CLASS_MATRIX &&
src
->dimx >=
ds
t->dimx &&
src
->dimy >=
ds
t->dimy)
return true;
/* Matrix-vector conversion is apparently allowed if they have the same components count */
if ((
t1
->type == HLSL_CLASS_VECTOR || t
2
->type == HLSL_CLASS_VECTOR)
&& hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
))
if ((
src
->type == HLSL_CLASS_VECTOR ||
ds
t->type == HLSL_CLASS_VECTOR)
&& hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t))
return true;
return false;
}
if (hlsl_type_component_count(
t1
) >= hlsl_type_component_count(t
2
))
if (hlsl_type_component_count(
src
) >= hlsl_type_component_count(
ds
t))
return true;
return false;
}
static bool implicit_compatible_data_types(struct hlsl_type *
t1
, struct hlsl_type *t
2
)
static bool implicit_compatible_data_types(struct hlsl_type *
src
, struct hlsl_type *
ds
t)
{
if (!convertible_data_type(
t1
) || !convertible_data_type(t
2
))
if (!convertible_data_type(
src
) || !convertible_data_type(
ds
t))
return false;
if (
t1
->type <= HLSL_CLASS_LAST_NUMERIC)
if (
src
->type <= HLSL_CLASS_LAST_NUMERIC)
{
/* Scalar vars can be converted to any other numeric data type */
if (
t1
->dimx == 1 &&
t1
->dimy == 1 && t
2
->type <= HLSL_CLASS_LAST_NUMERIC)
if (
src
->dimx == 1 &&
src
->dimy == 1 &&
ds
t->type <= HLSL_CLASS_LAST_NUMERIC)
return true;
/* The other way around is true too */
if (t
2
->dimx == 1 && t
2
->dimy == 1 && t
2
->type <= HLSL_CLASS_LAST_NUMERIC)
if (
ds
t->dimx == 1 &&
ds
t->dimy == 1 &&
ds
t->type <= HLSL_CLASS_LAST_NUMERIC)
return true;
}
if (
t1
->type == HLSL_CLASS_ARRAY && t
2
->type == HLSL_CLASS_ARRAY)
if (
src
->type == HLSL_CLASS_ARRAY &&
ds
t->type == HLSL_CLASS_ARRAY)
{
return hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
);
return hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t);
}
if ((
t1
->type == HLSL_CLASS_ARRAY && t
2
->type <= HLSL_CLASS_LAST_NUMERIC)
|| (
t1
->type <= HLSL_CLASS_LAST_NUMERIC && t
2
->type == HLSL_CLASS_ARRAY))
if ((
src
->type == HLSL_CLASS_ARRAY &&
ds
t->type <= HLSL_CLASS_LAST_NUMERIC)
|| (
src
->type <= HLSL_CLASS_LAST_NUMERIC &&
ds
t->type == HLSL_CLASS_ARRAY))
{
/* e.g. float4[3] to float4 is allowed */
if (
t1
->type == HLSL_CLASS_ARRAY && hlsl_types_are_equal(
t1
->e.array.type, t
2
))
if (
src
->type == HLSL_CLASS_ARRAY && hlsl_types_are_equal(
src
->e.array.type,
ds
t))
return true;
if (hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
))
if (hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t))
return true;
return false;
}
if (
t1
->type <= HLSL_CLASS_VECTOR && t
2
->type <= HLSL_CLASS_VECTOR)
if (
src
->type <= HLSL_CLASS_VECTOR &&
ds
t->type <= HLSL_CLASS_VECTOR)
{
if (
t1
->dimx >= t
2
->dimx)
if (
src
->dimx >=
ds
t->dimx)
return true;
return false;
}
if (
t1
->type == HLSL_CLASS_MATRIX || t
2
->type == HLSL_CLASS_MATRIX)
if (
src
->type == HLSL_CLASS_MATRIX ||
ds
t->type == HLSL_CLASS_MATRIX)
{
if (
t1
->type == HLSL_CLASS_MATRIX && t
2
->type == HLSL_CLASS_MATRIX)
return
t1
->dimx >= t
2
->dimx &&
t1
->dimy >= t
2
->dimy;
if (
src
->type == HLSL_CLASS_MATRIX &&
ds
t->type == HLSL_CLASS_MATRIX)
return
src
->dimx >=
ds
t->dimx &&
src
->dimy >=
ds
t->dimy;
/* Matrix-vector conversion is apparently allowed if they have
* the same components count, or if the matrix is 1xN or Nx1
* and we are reducing the component count */
if (
t1
->type == HLSL_CLASS_VECTOR || t
2
->type == HLSL_CLASS_VECTOR)
if (
src
->type == HLSL_CLASS_VECTOR ||
ds
t->type == HLSL_CLASS_VECTOR)
{
if (hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
))
if (hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t))
return true;
if ((
t1
->type == HLSL_CLASS_VECTOR ||
t1
->dimx == 1 ||
t1
->dimy == 1) &&
(t
2
->type == HLSL_CLASS_VECTOR || t
2
->dimx == 1 || t
2
->dimy == 1))
return hlsl_type_component_count(
t1
) >= hlsl_type_component_count(t
2
);
if ((
src
->type == HLSL_CLASS_VECTOR ||
src
->dimx == 1 ||
src
->dimy == 1) &&
(
ds
t->type == HLSL_CLASS_VECTOR ||
ds
t->dimx == 1 ||
ds
t->dimy == 1))
return hlsl_type_component_count(
src
) >= hlsl_type_component_count(
ds
t);
}
return false;
}
if (
t1
->type == HLSL_CLASS_STRUCT && t
2
->type == HLSL_CLASS_STRUCT)
return hlsl_types_are_equal(
t1, t2
);
if (
src
->type == HLSL_CLASS_STRUCT &&
ds
t->type == HLSL_CLASS_STRUCT)
return hlsl_types_are_equal(
src, dst
);
return false;
}
...
...
@@ -1167,34 +1167,34 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
}
}
static bool expr_compatible_data_types(struct hlsl_type *
t1
, struct hlsl_type *t
2
)
static bool expr_compatible_data_types(struct hlsl_type *
src
, struct hlsl_type *
ds
t)
{
if (
t1
->base_type > HLSL_TYPE_LAST_SCALAR || t
2
->base_type > HLSL_TYPE_LAST_SCALAR)
if (
src
->base_type > HLSL_TYPE_LAST_SCALAR ||
ds
t->base_type > HLSL_TYPE_LAST_SCALAR)
return false;
/* Scalar vars can be converted to pretty much everything */
if ((
t1
->dimx == 1 &&
t1
->dimy == 1) || (t
2
->dimx == 1 && t
2
->dimy == 1))
if ((
src
->dimx == 1 &&
src
->dimy == 1) || (
ds
t->dimx == 1 &&
ds
t->dimy == 1))
return true;
if (
t1
->type == HLSL_CLASS_VECTOR && t
2
->type == HLSL_CLASS_VECTOR)
if (
src
->type == HLSL_CLASS_VECTOR &&
ds
t->type == HLSL_CLASS_VECTOR)
return true;
if (
t1
->type == HLSL_CLASS_MATRIX || t
2
->type == HLSL_CLASS_MATRIX)
if (
src
->type == HLSL_CLASS_MATRIX ||
ds
t->type == HLSL_CLASS_MATRIX)
{
/* Matrix-vector conversion is apparently allowed if either they have the same components
count or the matrix is nx1 or 1xn */
if (
t1
->type == HLSL_CLASS_VECTOR || t
2
->type == HLSL_CLASS_VECTOR)
if (
src
->type == HLSL_CLASS_VECTOR ||
ds
t->type == HLSL_CLASS_VECTOR)
{
if (hlsl_type_component_count(
t1
) == hlsl_type_component_count(t
2
))
if (hlsl_type_component_count(
src
) == hlsl_type_component_count(
ds
t))
return true;
return (
t1
->type == HLSL_CLASS_MATRIX && (
t1
->dimx == 1 ||
t1
->dimy == 1))
|| (t
2
->type == HLSL_CLASS_MATRIX && (t
2
->dimx == 1 || t
2
->dimy == 1));
return (
src
->type == HLSL_CLASS_MATRIX && (
src
->dimx == 1 ||
src
->dimy == 1))
|| (
ds
t->type == HLSL_CLASS_MATRIX && (
ds
t->dimx == 1 ||
ds
t->dimy == 1));
}
/* Both matrices */
if ((
t1
->dimx >= t
2
->dimx &&
t1
->dimy >= t
2
->dimy)
|| (
t1
->dimx <= t
2
->dimx &&
t1
->dimy <= t
2
->dimy))
if ((
src
->dimx >=
ds
t->dimx &&
src
->dimy >=
ds
t->dimy)
|| (
src
->dimx <=
ds
t->dimx &&
src
->dimy <=
ds
t->dimy))
return true;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment