From 14e39627cc1294394d002e9892b1d28218086d59 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 5 Dec 2024 10:03:01 +0900 Subject: [PATCH] [qfcc] Construct matrices by vectors SPIR-V requires that matrices are constructed from vectors rather than individual components. While not optimal, iqm.vert's output now passes spirv-val. Also probably still lots wrong with fine details. --- tools/qfcc/source/expr_construct.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/expr_construct.c b/tools/qfcc/source/expr_construct.c index 850c30cc0..e2fb88471 100644 --- a/tools/qfcc/source/expr_construct.c +++ b/tools/qfcc/source/expr_construct.c @@ -130,7 +130,21 @@ construct_by_components (const type_t *type, const expr_t *params, auto vec = new_expr (); vec->type = ex_vector; vec->vector.type = type; - list_gather (&vec->vector.list, components, num_comp); + if (is_matrix (type)) { + const expr_t *columns[type_cols (type)]; + const expr_t **col = components; + for (int i = 0; i < type_cols (type); i++) { + auto c = new_expr (); + c->type = ex_vector; + c->vector.type = column_type (type); + list_gather (&c->vector.list, col, type_rows (type)); + columns[i] = c; + col += type_rows (type); + } + list_gather (&vec->vector.list, columns, type_cols (type)); + } else { + list_gather (&vec->vector.list, components, num_comp); + } return vec; }