glsl: fix indentation in emit_inline_matrix_constructor

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Iago Toral Quiroga
2016-02-19 09:14:19 +01:00
parent 04ad05c987
commit ad22886ef1

View File

@@ -1405,9 +1405,9 @@ emit_inline_matrix_constructor(const glsl_type *type,
zero.d[i] = 0.0; zero.d[i] = 0.0;
ir_instruction *inst = ir_instruction *inst =
new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var), new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var),
new(ctx) ir_constant(rhs_var->type, &zero), new(ctx) ir_constant(rhs_var->type, &zero),
NULL); NULL);
instructions->push_tail(inst); instructions->push_tail(inst);
ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var);
@@ -1422,36 +1422,36 @@ emit_inline_matrix_constructor(const glsl_type *type,
* columns than rows). * columns than rows).
*/ */
static const unsigned rhs_swiz[4][4] = { static const unsigned rhs_swiz[4][4] = {
{ 0, 1, 1, 1 }, { 0, 1, 1, 1 },
{ 1, 0, 1, 1 }, { 1, 0, 1, 1 },
{ 1, 1, 0, 1 }, { 1, 1, 0, 1 },
{ 1, 1, 1, 0 } { 1, 1, 1, 0 }
}; };
const unsigned cols_to_init = MIN2(type->matrix_columns, const unsigned cols_to_init = MIN2(type->matrix_columns,
type->vector_elements); type->vector_elements);
for (unsigned i = 0; i < cols_to_init; i++) { for (unsigned i = 0; i < cols_to_init; i++) {
ir_constant *const col_idx = new(ctx) ir_constant(i); ir_constant *const col_idx = new(ctx) ir_constant(i);
ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx);
ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var);
ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i], ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i],
type->vector_elements); type->vector_elements);
inst = new(ctx) ir_assignment(col_ref, rhs, NULL); inst = new(ctx) ir_assignment(col_ref, rhs, NULL);
instructions->push_tail(inst); instructions->push_tail(inst);
} }
for (unsigned i = cols_to_init; i < type->matrix_columns; i++) { for (unsigned i = cols_to_init; i < type->matrix_columns; i++) {
ir_constant *const col_idx = new(ctx) ir_constant(i); ir_constant *const col_idx = new(ctx) ir_constant(i);
ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx);
ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var);
ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1, ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1,
type->vector_elements); type->vector_elements);
inst = new(ctx) ir_assignment(col_ref, rhs, NULL); inst = new(ctx) ir_assignment(col_ref, rhs, NULL);
instructions->push_tail(inst); instructions->push_tail(inst);
} }
} else if (first_param->type->is_matrix()) { } else if (first_param->type->is_matrix()) {
/* From page 50 (56 of the PDF) of the GLSL 1.50 spec: /* From page 50 (56 of the PDF) of the GLSL 1.50 spec:
@@ -1469,36 +1469,36 @@ emit_inline_matrix_constructor(const glsl_type *type,
/* If the source matrix is smaller, pre-initialize the relavent parts of /* If the source matrix is smaller, pre-initialize the relavent parts of
* the destination matrix to the identity matrix. * the destination matrix to the identity matrix.
*/ */
if ((src_matrix->type->matrix_columns < var->type->matrix_columns) if ((src_matrix->type->matrix_columns < var->type->matrix_columns) ||
|| (src_matrix->type->vector_elements < var->type->vector_elements)) { (src_matrix->type->vector_elements < var->type->vector_elements)) {
/* If the source matrix has fewer rows, every column of the destination /* If the source matrix has fewer rows, every column of the destination
* must be initialized. Otherwise only the columns in the destination * must be initialized. Otherwise only the columns in the destination
* that do not exist in the source must be initialized. * that do not exist in the source must be initialized.
*/ */
unsigned col = unsigned col =
(src_matrix->type->vector_elements < var->type->vector_elements) (src_matrix->type->vector_elements < var->type->vector_elements)
? 0 : src_matrix->type->matrix_columns; ? 0 : src_matrix->type->matrix_columns;
const glsl_type *const col_type = var->type->column_type(); const glsl_type *const col_type = var->type->column_type();
for (/* empty */; col < var->type->matrix_columns; col++) { for (/* empty */; col < var->type->matrix_columns; col++) {
ir_constant_data ident; ir_constant_data ident;
ident.f[0] = 0.0; ident.f[0] = 0.0;
ident.f[1] = 0.0; ident.f[1] = 0.0;
ident.f[2] = 0.0; ident.f[2] = 0.0;
ident.f[3] = 0.0; ident.f[3] = 0.0;
ident.f[col] = 1.0; ident.f[col] = 1.0;
ir_rvalue *const rhs = new(ctx) ir_constant(col_type, &ident); ir_rvalue *const rhs = new(ctx) ir_constant(col_type, &ident);
ir_rvalue *const lhs = ir_rvalue *const lhs =
new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col)); new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col));
ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL);
instructions->push_tail(inst); instructions->push_tail(inst);
} }
} }
/* Assign columns from the source matrix to the destination matrix. /* Assign columns from the source matrix to the destination matrix.
@@ -1507,51 +1507,51 @@ emit_inline_matrix_constructor(const glsl_type *type,
* generate a temporary and copy the paramter there. * generate a temporary and copy the paramter there.
*/ */
ir_variable *const rhs_var = ir_variable *const rhs_var =
new(ctx) ir_variable(first_param->type, "mat_ctor_mat", new(ctx) ir_variable(first_param->type, "mat_ctor_mat",
ir_var_temporary); ir_var_temporary);
instructions->push_tail(rhs_var); instructions->push_tail(rhs_var);
ir_dereference *const rhs_var_ref = ir_dereference *const rhs_var_ref =
new(ctx) ir_dereference_variable(rhs_var); new(ctx) ir_dereference_variable(rhs_var);
ir_instruction *const inst = ir_instruction *const inst =
new(ctx) ir_assignment(rhs_var_ref, first_param, NULL); new(ctx) ir_assignment(rhs_var_ref, first_param, NULL);
instructions->push_tail(inst); instructions->push_tail(inst);
const unsigned last_row = MIN2(src_matrix->type->vector_elements, const unsigned last_row = MIN2(src_matrix->type->vector_elements,
var->type->vector_elements); var->type->vector_elements);
const unsigned last_col = MIN2(src_matrix->type->matrix_columns, const unsigned last_col = MIN2(src_matrix->type->matrix_columns,
var->type->matrix_columns); var->type->matrix_columns);
unsigned swiz[4] = { 0, 0, 0, 0 }; unsigned swiz[4] = { 0, 0, 0, 0 };
for (unsigned i = 1; i < last_row; i++) for (unsigned i = 1; i < last_row; i++)
swiz[i] = i; swiz[i] = i;
const unsigned write_mask = (1U << last_row) - 1; const unsigned write_mask = (1U << last_row) - 1;
for (unsigned i = 0; i < last_col; i++) { for (unsigned i = 0; i < last_col; i++) {
ir_dereference *const lhs = ir_dereference *const lhs =
new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i));
ir_rvalue *const rhs_col = ir_rvalue *const rhs_col =
new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i)); new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i));
/* If one matrix has columns that are smaller than the columns of the /* If one matrix has columns that are smaller than the columns of the
* other matrix, wrap the column access of the larger with a swizzle * other matrix, wrap the column access of the larger with a swizzle
* so that the LHS and RHS of the assignment have the same size (and * so that the LHS and RHS of the assignment have the same size (and
* therefore have the same type). * therefore have the same type).
* *
* It would be perfectly valid to unconditionally generate the * It would be perfectly valid to unconditionally generate the
* swizzles, this this will typically result in a more compact IR tree. * swizzles, this this will typically result in a more compact IR tree.
*/ */
ir_rvalue *rhs; ir_rvalue *rhs;
if (lhs->type->vector_elements != rhs_col->type->vector_elements) { if (lhs->type->vector_elements != rhs_col->type->vector_elements) {
rhs = new(ctx) ir_swizzle(rhs_col, swiz, last_row); rhs = new(ctx) ir_swizzle(rhs_col, swiz, last_row);
} else { } else {
rhs = rhs_col; rhs = rhs_col;
} }
ir_instruction *inst = ir_instruction *inst =
new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
instructions->push_tail(inst); instructions->push_tail(inst);
} }
} else { } else {
const unsigned cols = type->matrix_columns; const unsigned cols = type->matrix_columns;