[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.
This commit is contained in:
Bill Currie 2024-12-05 10:03:01 +09:00
parent f014d3f580
commit 14e39627cc

View file

@ -130,7 +130,21 @@ construct_by_components (const type_t *type, const expr_t *params,
auto vec = new_expr (); auto vec = new_expr ();
vec->type = ex_vector; vec->type = ex_vector;
vec->vector.type = type; 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; return vec;
} }