Giovanni Mascellani : vkd3d-shader/hlsl: Allow more implicit conversions between matrices and vectors.
Alexandre Julliard
julliard at winehq.org
Mon Nov 1 16:33:18 CDT 2021
Module: vkd3d
Branch: master
Commit: fc053b1c086d9a051c7baaaa4f7b83c385963e10
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=fc053b1c086d9a051c7baaaa4f7b83c385963e10
Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date: Mon Oct 25 09:06:30 2021 +0200
vkd3d-shader/hlsl: Allow more implicit conversions between matrices and vectors.
HLSL seems to treat matrices 1xN or Nx1 as vectors when looking for
implicit conversions.
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.y | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 249d1bf..a2e27b5 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -240,14 +240,22 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
if (t1->type == HLSL_CLASS_MATRIX || t2->type == HLSL_CLASS_MATRIX)
{
- if (t1->type == HLSL_CLASS_MATRIX && t2->type == HLSL_CLASS_MATRIX
- && t1->dimx >= t2->dimx && t1->dimy >= t2->dimy)
- return true;
+ if (t1->type == HLSL_CLASS_MATRIX && t2->type == HLSL_CLASS_MATRIX)
+ return t1->dimx >= t2->dimx && t1->dimy >= t2->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 || t2->type == HLSL_CLASS_VECTOR)
+ {
+ if (hlsl_type_component_count(t1) == hlsl_type_component_count(t2))
+ return true;
+
+ if ((t1->type == HLSL_CLASS_VECTOR || t1->dimx == 1 || t1->dimy == 1) &&
+ (t2->type == HLSL_CLASS_VECTOR || t2->dimx == 1 || t2->dimy == 1))
+ return hlsl_type_component_count(t1) >= hlsl_type_component_count(t2);
+ }
- /* Matrix-vector conversion is apparently allowed if they have the same components count */
- if ((t1->type == HLSL_CLASS_VECTOR || t2->type == HLSL_CLASS_VECTOR)
- && hlsl_type_component_count(t1) == hlsl_type_component_count(t2))
- return true;
return false;
}
More information about the wine-cvs
mailing list