Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- 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)