mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 22:10:10 +01:00
spirv: Use nir_vec_scalars() to simplify matrix transpose.
This should emit fewer instructions that need to be copy-propagated away. Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16465>
This commit is contained in:
parent
633cf4eca1
commit
87d7431198
1 changed files with 6 additions and 9 deletions
|
|
@ -3872,19 +3872,16 @@ vtn_ssa_transpose(struct vtn_builder *b, struct vtn_ssa_value *src)
|
||||||
vtn_create_ssa_value(b, glsl_transposed_type(src->type));
|
vtn_create_ssa_value(b, glsl_transposed_type(src->type));
|
||||||
|
|
||||||
for (unsigned i = 0; i < glsl_get_matrix_columns(dest->type); i++) {
|
for (unsigned i = 0; i < glsl_get_matrix_columns(dest->type); i++) {
|
||||||
nir_alu_instr *vec = create_vec(b, glsl_get_matrix_columns(src->type),
|
|
||||||
glsl_get_bit_size(src->type));
|
|
||||||
if (glsl_type_is_vector_or_scalar(src->type)) {
|
if (glsl_type_is_vector_or_scalar(src->type)) {
|
||||||
vec->src[0].src = nir_src_for_ssa(src->def);
|
dest->elems[i]->def = nir_channel(&b->nb, src->def, i);
|
||||||
vec->src[0].swizzle[0] = i;
|
|
||||||
} else {
|
} else {
|
||||||
for (unsigned j = 0; j < glsl_get_matrix_columns(src->type); j++) {
|
unsigned cols = glsl_get_matrix_columns(src->type);
|
||||||
vec->src[j].src = nir_src_for_ssa(src->elems[j]->def);
|
nir_ssa_scalar srcs[cols];
|
||||||
vec->src[j].swizzle[0] = i;
|
for (unsigned j = 0; j < cols; j++) {
|
||||||
|
srcs[j] = nir_get_ssa_scalar(src->elems[j]->def, i);
|
||||||
}
|
}
|
||||||
|
dest->elems[i]->def = nir_vec_scalars(&b->nb, srcs, cols);
|
||||||
}
|
}
|
||||||
nir_builder_instr_insert(&b->nb, &vec->instr);
|
|
||||||
dest->elems[i]->def = &vec->dest.dest.ssa;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->transposed = src;
|
dest->transposed = src;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue