Giovanni Mascellani : vkd3d-shader/hlsl: Support vector indexing.

Alexandre Julliard julliard at winehq.org
Wed Apr 20 16:48:25 CDT 2022


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

Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date:   Mon Apr 18 08:34:01 2022 +0200

vkd3d-shader/hlsl: Support vector indexing.

Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/hlsl.y               | 14 ++++++++++----
 tests/hlsl-vector-indexing.shader_test |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index fd808648..291f8392 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -592,13 +592,21 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
     if (expr_type->type == HLSL_CLASS_ARRAY)
     {
         data_type = expr_type->e.array.type;
+        if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
+            return false;
     }
-    else if (expr_type->type == HLSL_CLASS_MATRIX || expr_type->type == HLSL_CLASS_VECTOR)
+    else if (expr_type->type == HLSL_CLASS_MATRIX)
     {
         /* This needs to be lowered now, while we still have type information. */
-        FIXME("Index of matrix or vector type.\n");
+        FIXME("Index of matrix type.\n");
         return false;
     }
+    else if (expr_type->type == HLSL_CLASS_VECTOR)
+    {
+        data_type = hlsl_get_scalar_type(ctx, expr_type->base_type);
+        if (!(c = hlsl_new_uint_constant(ctx, 1, &loc)))
+            return false;
+    }
     else
     {
         if (expr_type->type == HLSL_CLASS_SCALAR)
@@ -608,8 +616,6 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
         return false;
     }
 
-    if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
-        return false;
     list_add_tail(instrs, &c->node.entry);
     if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node)))
         return false;
diff --git a/tests/hlsl-vector-indexing.shader_test b/tests/hlsl-vector-indexing.shader_test
index 1c964147..f2d20c44 100644
--- a/tests/hlsl-vector-indexing.shader_test
+++ b/tests/hlsl-vector-indexing.shader_test
@@ -10,7 +10,7 @@ float4 main() : SV_TARGET
 }
 
 [test]
-todo draw quad
+draw quad
 probe all rgba (0.02, 0.245, 0.351, 1.0)
 
 [pixel shader]
@@ -23,5 +23,5 @@ float4 main() : SV_TARGET
 
 [test]
 uniform 0 float4 1.0 2.0 3.0 4.0
-todo draw quad
+draw quad
 probe all rgba (1.0, 2.0, 2.0, 3.0)




More information about the wine-cvs mailing list