Zebediah Figura : vkd3d-shader: Allow declarations to specify type modifiers redundant with the type.

Alexandre Julliard julliard at winehq.org
Mon Jun 28 16:49:05 CDT 2021


Module: vkd3d
Branch: master
Commit: 1dbb14645423437a6dfc370a0b4d550446efe383
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=1dbb14645423437a6dfc370a0b4d550446efe383

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Wed Jun 23 23:57:31 2021 -0500

vkd3d-shader: Allow declarations to specify type modifiers redundant with the type.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 Makefile.am                                |  2 ++
 libs/vkd3d-shader/hlsl.y                   |  6 +++++-
 tests/hlsl-duplicate-modifiers.shader_test | 11 +++++++++++
 tests/hlsl-invalid.shader_test             | 17 +++++++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index e853786..5b3c4ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,6 +57,7 @@ vkd3d_shader_tests = \
 	tests/conditional.shader_test \
 	tests/hlsl-array-dimension.shader_test \
 	tests/hlsl-comma.shader_test \
+	tests/hlsl-duplicate-modifiers.shader_test \
 	tests/hlsl-invalid.shader_test \
 	tests/hlsl-majority-pragma.shader_test \
 	tests/hlsl-majority-typedef.shader_test \
@@ -256,6 +257,7 @@ XFAIL_TESTS = \
 	tests/conditional.shader_test \
 	tests/hlsl-array-dimension.shader_test \
 	tests/hlsl-comma.shader_test \
+	tests/hlsl-duplicate-modifiers.shader_test \
 	tests/hlsl-majority-pragma.shader_test \
 	tests/hlsl-majority-typedef.shader_test \
 	tests/hlsl-nested-arrays.shader_test \
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 828b19a..513c451 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -659,9 +659,13 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
     if (!(new_type = hlsl_type_clone(ctx, type, default_majority)))
         return NULL;
 
-    new_type->modifiers = add_modifiers(ctx, new_type->modifiers, *modifiers, loc);
+    new_type->modifiers |= *modifiers;
     *modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
 
+    if ((new_type->modifiers & HLSL_MODIFIER_ROW_MAJOR) && (new_type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR))
+        hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+                "'row_major' and 'column_major' modifiers are mutually exclusive.");
+
     if (new_type->type == HLSL_CLASS_MATRIX)
         new_type->reg_size = (hlsl_type_is_row_major(new_type) ? new_type->dimy : new_type->dimx) * 4;
     return new_type;
diff --git a/tests/hlsl-duplicate-modifiers.shader_test b/tests/hlsl-duplicate-modifiers.shader_test
new file mode 100644
index 0000000..6491701
--- /dev/null
+++ b/tests/hlsl-duplicate-modifiers.shader_test
@@ -0,0 +1,11 @@
+[pixel shader]
+typedef const precise row_major float2x2 mat_t;
+float4 main() : sv_target
+{
+    const precise row_major mat_t mat = float2x2(0.1, 0.2, 0.3, 0.4);
+    return mat;
+}
+
+[test]
+draw quad
+probe all rgba (0.1, 0.2, 0.3, 0.4)
diff --git a/tests/hlsl-invalid.shader_test b/tests/hlsl-invalid.shader_test
index 7205598..f6a7ffd 100644
--- a/tests/hlsl-invalid.shader_test
+++ b/tests/hlsl-invalid.shader_test
@@ -219,3 +219,20 @@ float4 main(void) : sv_target
     in float f;
     return 0;
 }
+
+[pixel shader fail]
+const const float4 c;
+
+float4 main() : sv_target
+{
+    return float4(0, 0, 0, 0);
+}
+
+[pixel shader fail]
+typedef row_major float4x4 mat_t;
+column_major mat_t m;
+
+float4 main() : sv_target
+{
+    return float4(0, 0, 0, 0);
+}




More information about the wine-cvs mailing list