summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-06-10 10:00:14 +1000
committerDave Airlie <airlied@redhat.com>2016-06-10 10:30:18 +1000
commitf140ed6d956d3595551d34836029325f1ae819d6 (patch)
treed123235b47e22fc902d60c7a5296140d45499966 /src/compiler/glsl/ir_constant_expression.cpp
parent73a54e4892331ca21cb49f4737b27d1c12401681 (diff)
downloadexternal_mesa3d-f140ed6d956d3595551d34836029325f1ae819d6.zip
external_mesa3d-f140ed6d956d3595551d34836029325f1ae819d6.tar.gz
external_mesa3d-f140ed6d956d3595551d34836029325f1ae819d6.tar.bz2
glsl/ir: remove TABs in ir_constant_expression.cpp
Adding 64-bit integers support was going to make this file worse, just remove the tabs from it now. Acked-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/compiler/glsl/ir_constant_expression.cpp')
-rw-r--r--src/compiler/glsl/ir_constant_expression.cpp1070
1 files changed, 535 insertions, 535 deletions
diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp
index fbbf779..d961aa9 100644
--- a/src/compiler/glsl/ir_constant_expression.cpp
+++ b/src/compiler/glsl/ir_constant_expression.cpp
@@ -491,7 +491,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
for (unsigned operand = 0; operand < this->get_num_operands(); operand++) {
op[operand] = this->operands[operand]->constant_expression_value(variable_context);
if (!op[operand])
- return NULL;
+ return NULL;
}
if (op[1] != NULL)
@@ -533,11 +533,11 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
assert(op[1] != NULL && op[1]->type->is_array());
switch (this->operation) {
case ir_binop_all_equal:
- return new(ctx) ir_constant(op[0]->has_value(op[1]));
+ return new(ctx) ir_constant(op[0]->has_value(op[1]));
case ir_binop_any_nequal:
- return new(ctx) ir_constant(!op[0]->has_value(op[1]));
+ return new(ctx) ir_constant(!op[0]->has_value(op[1]));
default:
- break;
+ break;
}
return NULL;
}
@@ -561,13 +561,13 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_unop_logic_not:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.b[c] = !op[0]->value.b[c];
+ data.b[c] = !op[0]->value.b[c];
break;
case ir_unop_f2i:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.i[c] = (int) op[0]->value.f[c];
+ data.i[c] = (int) op[0]->value.f[c];
}
break;
case ir_unop_f2u:
@@ -579,109 +579,109 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_unop_i2f:
assert(op[0]->type->base_type == GLSL_TYPE_INT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = (float) op[0]->value.i[c];
+ data.f[c] = (float) op[0]->value.i[c];
}
break;
case ir_unop_u2f:
assert(op[0]->type->base_type == GLSL_TYPE_UINT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = (float) op[0]->value.u[c];
+ data.f[c] = (float) op[0]->value.u[c];
}
break;
case ir_unop_b2f:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = op[0]->value.b[c] ? 1.0F : 0.0F;
+ data.f[c] = op[0]->value.b[c] ? 1.0F : 0.0F;
}
break;
case ir_unop_f2b:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.b[c] = op[0]->value.f[c] != 0.0F ? true : false;
+ data.b[c] = op[0]->value.f[c] != 0.0F ? true : false;
}
break;
case ir_unop_b2i:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.u[c] = op[0]->value.b[c] ? 1 : 0;
+ data.u[c] = op[0]->value.b[c] ? 1 : 0;
}
break;
case ir_unop_i2b:
assert(op[0]->type->is_integer());
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.b[c] = op[0]->value.u[c] ? true : false;
+ data.b[c] = op[0]->value.u[c] ? true : false;
}
break;
case ir_unop_u2i:
assert(op[0]->type->base_type == GLSL_TYPE_UINT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.i[c] = op[0]->value.u[c];
+ data.i[c] = op[0]->value.u[c];
}
break;
case ir_unop_i2u:
assert(op[0]->type->base_type == GLSL_TYPE_INT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.u[c] = op[0]->value.i[c];
+ data.u[c] = op[0]->value.i[c];
}
break;
case ir_unop_bitcast_i2f:
assert(op[0]->type->base_type == GLSL_TYPE_INT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = bitcast_u2f(op[0]->value.i[c]);
+ data.f[c] = bitcast_u2f(op[0]->value.i[c]);
}
break;
case ir_unop_bitcast_f2i:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.i[c] = bitcast_f2u(op[0]->value.f[c]);
+ data.i[c] = bitcast_f2u(op[0]->value.f[c]);
}
break;
case ir_unop_bitcast_u2f:
assert(op[0]->type->base_type == GLSL_TYPE_UINT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = bitcast_u2f(op[0]->value.u[c]);
+ data.f[c] = bitcast_u2f(op[0]->value.u[c]);
}
break;
case ir_unop_bitcast_f2u:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.u[c] = bitcast_f2u(op[0]->value.f[c]);
+ data.u[c] = bitcast_f2u(op[0]->value.f[c]);
}
break;
case ir_unop_d2f:
assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = op[0]->value.d[c];
+ data.f[c] = op[0]->value.d[c];
}
break;
case ir_unop_f2d:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.d[c] = op[0]->value.f[c];
+ data.d[c] = op[0]->value.f[c];
}
break;
case ir_unop_d2i:
assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.i[c] = op[0]->value.d[c];
+ data.i[c] = op[0]->value.d[c];
}
break;
case ir_unop_i2d:
assert(op[0]->type->base_type == GLSL_TYPE_INT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.d[c] = op[0]->value.i[c];
+ data.d[c] = op[0]->value.i[c];
}
break;
case ir_unop_d2u:
assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.u[c] = op[0]->value.d[c];
+ data.u[c] = op[0]->value.d[c];
}
break;
case ir_unop_u2d:
assert(op[0]->type->base_type == GLSL_TYPE_UINT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.d[c] = op[0]->value.u[c];
+ data.d[c] = op[0]->value.u[c];
}
break;
case ir_unop_d2b:
@@ -728,126 +728,126 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_unop_fract:
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = 0;
- break;
- case GLSL_TYPE_INT:
- data.i[c] = 0;
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]);
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = op[0]->value.d[c] - floor(op[0]->value.d[c]);
- break;
- default:
- assert(0);
- }
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = 0;
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = 0;
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]);
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = op[0]->value.d[c] - floor(op[0]->value.d[c]);
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_unop_sin:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = sinf(op[0]->value.f[c]);
+ data.f[c] = sinf(op[0]->value.f[c]);
}
break;
case ir_unop_cos:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = cosf(op[0]->value.f[c]);
+ data.f[c] = cosf(op[0]->value.f[c]);
}
break;
case ir_unop_neg:
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = -((int) op[0]->value.u[c]);
- break;
- case GLSL_TYPE_INT:
- data.i[c] = -op[0]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = -op[0]->value.f[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = -op[0]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = -((int) op[0]->value.u[c]);
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = -op[0]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = -op[0]->value.f[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = -op[0]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_unop_abs:
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = op[0]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.i[c] = op[0]->value.i[c];
- if (data.i[c] < 0)
- data.i[c] = -data.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = fabs(op[0]->value.f[c]);
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = fabs(op[0]->value.d[c]);
- break;
- default:
- assert(0);
- }
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[0]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = op[0]->value.i[c];
+ if (data.i[c] < 0)
+ data.i[c] = -data.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = fabs(op[0]->value.f[c]);
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = fabs(op[0]->value.d[c]);
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_unop_sign:
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = op[0]->value.i[c] > 0;
- break;
- case GLSL_TYPE_INT:
- data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0));
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = double((op[0]->value.d[c] > 0)-(op[0]->value.d[c] < 0));
- break;
- default:
- assert(0);
- }
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[0]->value.i[c] > 0;
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0));
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = double((op[0]->value.d[c] > 0)-(op[0]->value.d[c] < 0));
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_unop_rcp:
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_UINT:
- if (op[0]->value.u[c] != 0.0)
- data.u[c] = 1 / op[0]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- if (op[0]->value.i[c] != 0.0)
- data.i[c] = 1 / op[0]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- if (op[0]->value.f[c] != 0.0)
- data.f[c] = 1.0F / op[0]->value.f[c];
- break;
- case GLSL_TYPE_DOUBLE:
- if (op[0]->value.d[c] != 0.0)
- data.d[c] = 1.0 / op[0]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ if (op[0]->value.u[c] != 0.0)
+ data.u[c] = 1 / op[0]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ if (op[0]->value.i[c] != 0.0)
+ data.i[c] = 1 / op[0]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ if (op[0]->value.f[c] != 0.0)
+ data.f[c] = 1.0F / op[0]->value.f[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ if (op[0]->value.d[c] != 0.0)
+ data.d[c] = 1.0 / op[0]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
@@ -872,28 +872,28 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_unop_exp:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = expf(op[0]->value.f[c]);
+ data.f[c] = expf(op[0]->value.f[c]);
}
break;
case ir_unop_exp2:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = exp2f(op[0]->value.f[c]);
+ data.f[c] = exp2f(op[0]->value.f[c]);
}
break;
case ir_unop_log:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = logf(op[0]->value.f[c]);
+ data.f[c] = logf(op[0]->value.f[c]);
}
break;
case ir_unop_log2:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = log2f(op[0]->value.f[c]);
+ data.f[c] = log2f(op[0]->value.f[c]);
}
break;
@@ -905,7 +905,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_unop_dFdy_fine:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = 0.0;
+ data.f[c] = 0.0;
}
break;
@@ -976,7 +976,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_binop_pow:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]);
+ data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]);
}
break;
@@ -990,154 +990,154 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_binop_min:
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]);
- break;
- case GLSL_TYPE_INT:
- data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]);
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]);
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = MIN2(op[0]->value.d[c0], op[1]->value.d[c1]);
- break;
- default:
- assert(0);
- }
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]);
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]);
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]);
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = MIN2(op[0]->value.d[c0], op[1]->value.d[c1]);
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_max:
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]);
- break;
- case GLSL_TYPE_INT:
- data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]);
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]);
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = MAX2(op[0]->value.d[c0], op[1]->value.d[c1]);
- break;
- default:
- assert(0);
- }
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]);
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]);
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]);
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = MAX2(op[0]->value.d[c0], op[1]->value.d[c1]);
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_add:
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1];
- break;
- case GLSL_TYPE_INT:
- data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1];
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1];
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = op[0]->value.d[c0] + op[1]->value.d[c1];
- break;
- default:
- assert(0);
- }
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1];
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = op[0]->value.d[c0] + op[1]->value.d[c1];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_sub:
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1];
- break;
- case GLSL_TYPE_INT:
- data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1];
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1];
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1];
- break;
- default:
- assert(0);
- }
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1];
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_mul:
/* Check for equal types, or unequal types involving scalars */
if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix())
- || op0_scalar || op1_scalar) {
- for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1];
- break;
- case GLSL_TYPE_INT:
- data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1];
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1];
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = op[0]->value.d[c0] * op[1]->value.d[c1];
- break;
- default:
- assert(0);
- }
- }
+ || op0_scalar || op1_scalar) {
+ for (unsigned c = 0, c0 = 0, c1 = 0;
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1];
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = op[0]->value.d[c0] * op[1]->value.d[c1];
+ break;
+ default:
+ assert(0);
+ }
+ }
} else {
- assert(op[0]->type->is_matrix() || op[1]->type->is_matrix());
-
- /* Multiply an N-by-M matrix with an M-by-P matrix. Since either
- * matrix can be a GLSL vector, either N or P can be 1.
- *
- * For vec*mat, the vector is treated as a row vector. This
- * means the vector is a 1-row x M-column matrix.
- *
- * For mat*vec, the vector is treated as a column vector. Since
- * matrix_columns is 1 for vectors, this just works.
- */
- const unsigned n = op[0]->type->is_vector()
- ? 1 : op[0]->type->vector_elements;
- const unsigned m = op[1]->type->vector_elements;
- const unsigned p = op[1]->type->matrix_columns;
- for (unsigned j = 0; j < p; j++) {
- for (unsigned i = 0; i < n; i++) {
- for (unsigned k = 0; k < m; k++) {
+ assert(op[0]->type->is_matrix() || op[1]->type->is_matrix());
+
+ /* Multiply an N-by-M matrix with an M-by-P matrix. Since either
+ * matrix can be a GLSL vector, either N or P can be 1.
+ *
+ * For vec*mat, the vector is treated as a row vector. This
+ * means the vector is a 1-row x M-column matrix.
+ *
+ * For mat*vec, the vector is treated as a column vector. Since
+ * matrix_columns is 1 for vectors, this just works.
+ */
+ const unsigned n = op[0]->type->is_vector()
+ ? 1 : op[0]->type->vector_elements;
+ const unsigned m = op[1]->type->vector_elements;
+ const unsigned p = op[1]->type->matrix_columns;
+ for (unsigned j = 0; j < p; j++) {
+ for (unsigned i = 0; i < n; i++) {
+ for (unsigned k = 0; k < m; k++) {
if (op[0]->type->base_type == GLSL_TYPE_DOUBLE)
data.d[i+n*j] += op[0]->value.d[i+n*k]*op[1]->value.d[k+m*j];
else
data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j];
- }
- }
- }
+ }
+ }
+ }
}
break;
@@ -1145,33 +1145,33 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
/* FINISHME: Emit warning when division-by-zero is detected. */
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- if (op[1]->value.u[c1] == 0) {
- data.u[c] = 0;
- } else {
- data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1];
- }
- break;
- case GLSL_TYPE_INT:
- if (op[1]->value.i[c1] == 0) {
- data.i[c] = 0;
- } else {
- data.i[c] = op[0]->value.i[c0] / op[1]->value.i[c1];
- }
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1];
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = op[0]->value.d[c0] / op[1]->value.d[c1];
- break;
- default:
- assert(0);
- }
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ if (op[1]->value.u[c1] == 0) {
+ data.u[c] = 0;
+ } else {
+ data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1];
+ }
+ break;
+ case GLSL_TYPE_INT:
+ if (op[1]->value.i[c1] == 0) {
+ data.i[c] = 0;
+ } else {
+ data.i[c] = op[0]->value.i[c0] / op[1]->value.i[c1];
+ }
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = op[0]->value.d[c0] / op[1]->value.d[c1];
+ break;
+ default:
+ assert(0);
+ }
}
break;
@@ -1179,41 +1179,41 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
/* FINISHME: Emit warning when division-by-zero is detected. */
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;
- c < components;
- c0 += c0_inc, c1 += c1_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- if (op[1]->value.u[c1] == 0) {
- data.u[c] = 0;
- } else {
- data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1];
- }
- break;
- case GLSL_TYPE_INT:
- if (op[1]->value.i[c1] == 0) {
- data.i[c] = 0;
- } else {
- data.i[c] = op[0]->value.i[c0] % op[1]->value.i[c1];
- }
- break;
- case GLSL_TYPE_FLOAT:
- /* We don't use fmod because it rounds toward zero; GLSL specifies
- * the use of floor.
- */
- data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1]
- * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]);
- break;
- case GLSL_TYPE_DOUBLE:
- /* We don't use fmod because it rounds toward zero; GLSL specifies
- * the use of floor.
- */
- data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1]
- * floor(op[0]->value.d[c0] / op[1]->value.d[c1]);
- break;
- default:
- assert(0);
- }
+ c < components;
+ c0 += c0_inc, c1 += c1_inc, c++) {
+
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ if (op[1]->value.u[c1] == 0) {
+ data.u[c] = 0;
+ } else {
+ data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1];
+ }
+ break;
+ case GLSL_TYPE_INT:
+ if (op[1]->value.i[c1] == 0) {
+ data.i[c] = 0;
+ } else {
+ data.i[c] = op[0]->value.i[c0] % op[1]->value.i[c1];
+ }
+ break;
+ case GLSL_TYPE_FLOAT:
+ /* We don't use fmod because it rounds toward zero; GLSL specifies
+ * the use of floor.
+ */
+ data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1]
+ * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]);
+ break;
+ case GLSL_TYPE_DOUBLE:
+ /* We don't use fmod because it rounds toward zero; GLSL specifies
+ * the use of floor.
+ */
+ data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1]
+ * floor(op[0]->value.d[c0] / op[1]->value.d[c1]);
+ break;
+ default:
+ assert(0);
+ }
}
break;
@@ -1221,149 +1221,149 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_binop_logic_and:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.b[c] = op[0]->value.b[c] && op[1]->value.b[c];
+ data.b[c] = op[0]->value.b[c] && op[1]->value.b[c];
break;
case ir_binop_logic_xor:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c];
+ data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c];
break;
case ir_binop_logic_or:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.b[c] = op[0]->value.b[c] || op[1]->value.b[c];
+ data.b[c] = op[0]->value.b[c] || op[1]->value.b[c];
break;
case ir_binop_less:
assert(op[0]->type == op[1]->type);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] < op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] < op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] < op[1]->value.f[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.b[c] = op[0]->value.d[c] < op[1]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] < op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] < op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] < op[1]->value.f[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.b[c] = op[0]->value.d[c] < op[1]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_greater:
assert(op[0]->type == op[1]->type);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] > op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] > op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] > op[1]->value.f[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.b[c] = op[0]->value.d[c] > op[1]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] > op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] > op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] > op[1]->value.f[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.b[c] = op[0]->value.d[c] > op[1]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_lequal:
assert(op[0]->type == op[1]->type);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.b[c] = op[0]->value.d[c] <= op[1]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.b[c] = op[0]->value.d[c] <= op[1]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_gequal:
assert(op[0]->type == op[1]->type);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.b[c] = op[0]->value.d[c] >= op[1]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.b[c] = op[0]->value.d[c] >= op[1]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_equal:
assert(op[0]->type == op[1]->type);
for (unsigned c = 0; c < components; c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
- break;
- case GLSL_TYPE_BOOL:
- data.b[c] = op[0]->value.b[c] == op[1]->value.b[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.b[c] = op[0]->value.d[c] == op[1]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
+ break;
+ case GLSL_TYPE_BOOL:
+ data.b[c] = op[0]->value.b[c] == op[1]->value.b[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.b[c] = op[0]->value.d[c] == op[1]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_nequal:
assert(op[0]->type == op[1]->type);
for (unsigned c = 0; c < components; c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] != op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] != op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] != op[1]->value.f[c];
- break;
- case GLSL_TYPE_BOOL:
- data.b[c] = op[0]->value.b[c] != op[1]->value.b[c];
- break;
- case GLSL_TYPE_DOUBLE:
- data.b[c] = op[0]->value.d[c] != op[1]->value.d[c];
- break;
- default:
- assert(0);
- }
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] != op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] != op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] != op[1]->value.f[c];
+ break;
+ case GLSL_TYPE_BOOL:
+ data.b[c] = op[0]->value.b[c] != op[1]->value.b[c];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.b[c] = op[0]->value.d[c] != op[1]->value.d[c];
+ break;
+ default:
+ assert(0);
+ }
}
break;
case ir_binop_all_equal:
@@ -1459,7 +1459,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_binop_vector_extract: {
const int c = CLAMP(op[1]->value.i[0], 0,
- (int) op[0]->type->vector_elements - 1);
+ (int) op[0]->type->vector_elements - 1);
switch (op[0]->type->base_type) {
case GLSL_TYPE_UINT:
@@ -1688,23 +1688,23 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
switch (this->type->base_type) {
case GLSL_TYPE_INT:
- data.i[idx] = op[1]->value.i[0];
- break;
+ data.i[idx] = op[1]->value.i[0];
+ break;
case GLSL_TYPE_UINT:
- data.u[idx] = op[1]->value.u[0];
- break;
+ data.u[idx] = op[1]->value.u[0];
+ break;
case GLSL_TYPE_FLOAT:
- data.f[idx] = op[1]->value.f[0];
- break;
+ data.f[idx] = op[1]->value.f[0];
+ break;
case GLSL_TYPE_BOOL:
- data.b[idx] = op[1]->value.b[0];
- break;
+ data.b[idx] = op[1]->value.b[0];
+ break;
case GLSL_TYPE_DOUBLE:
- data.d[idx] = op[1]->value.d[0];
- break;
+ data.d[idx] = op[1]->value.d[0];
+ break;
default:
- assert(!"Should not get here.");
- break;
+ assert(!"Should not get here.");
+ break;
}
break;
}
@@ -1738,22 +1738,22 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_quadop_vector:
for (unsigned c = 0; c < this->type->vector_elements; c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_INT:
- data.i[c] = op[c]->value.i[0];
- break;
- case GLSL_TYPE_UINT:
- data.u[c] = op[c]->value.u[0];
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = op[c]->value.f[0];
- break;
- case GLSL_TYPE_DOUBLE:
- data.d[c] = op[c]->value.d[0];
- break;
- default:
- assert(0);
- }
+ switch (this->type->base_type) {
+ case GLSL_TYPE_INT:
+ data.i[c] = op[c]->value.i[0];
+ break;
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[c]->value.u[0];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = op[c]->value.f[0];
+ break;
+ case GLSL_TYPE_DOUBLE:
+ data.d[c] = op[c]->value.d[0];
+ break;
+ default:
+ assert(0);
+ }
}
break;
@@ -1783,18 +1783,18 @@ ir_swizzle::constant_expression_value(struct hash_table *variable_context)
ir_constant_data data = { { 0 } };
const unsigned swiz_idx[4] = {
- this->mask.x, this->mask.y, this->mask.z, this->mask.w
+ this->mask.x, this->mask.y, this->mask.z, this->mask.w
};
for (unsigned i = 0; i < this->mask.num_components; i++) {
- switch (v->type->base_type) {
- case GLSL_TYPE_UINT:
- case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break;
- case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break;
- case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break;
- case GLSL_TYPE_DOUBLE:data.d[i] = v->value.d[swiz_idx[i]]; break;
- default: assert(!"Should not get here."); break;
- }
+ switch (v->type->base_type) {
+ case GLSL_TYPE_UINT:
+ case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break;
+ case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break;
+ case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break;
+ case GLSL_TYPE_DOUBLE:data.d[i] = v->value.d[swiz_idx[i]]; break;
+ default: assert(!"Should not get here."); break;
+ }
}
void *ctx = ralloc_parent(this);
@@ -1813,7 +1813,7 @@ ir_dereference_variable::constant_expression_value(struct hash_table *variable_c
if (variable_context) {
ir_constant *value = (ir_constant *)hash_table_find(variable_context, var);
if(value)
- return value;
+ return value;
}
/* The constant_value of a uniform variable is its initializer,
@@ -1838,52 +1838,52 @@ ir_dereference_array::constant_expression_value(struct hash_table *variable_cont
if ((array != NULL) && (idx != NULL)) {
void *ctx = ralloc_parent(this);
if (array->type->is_matrix()) {
- /* Array access of a matrix results in a vector.
- */
- const unsigned column = idx->value.u[0];
+ /* Array access of a matrix results in a vector.
+ */
+ const unsigned column = idx->value.u[0];
- const glsl_type *const column_type = array->type->column_type();
+ const glsl_type *const column_type = array->type->column_type();
- /* Offset in the constant matrix to the first element of the column
- * to be extracted.
- */
- const unsigned mat_idx = column * column_type->vector_elements;
+ /* Offset in the constant matrix to the first element of the column
+ * to be extracted.
+ */
+ const unsigned mat_idx = column * column_type->vector_elements;
- ir_constant_data data = { { 0 } };
+ ir_constant_data data = { { 0 } };
- switch (column_type->base_type) {
- case GLSL_TYPE_UINT:
- case GLSL_TYPE_INT:
- for (unsigned i = 0; i < column_type->vector_elements; i++)
- data.u[i] = array->value.u[mat_idx + i];
+ switch (column_type->base_type) {
+ case GLSL_TYPE_UINT:
+ case GLSL_TYPE_INT:
+ for (unsigned i = 0; i < column_type->vector_elements; i++)
+ data.u[i] = array->value.u[mat_idx + i];
- break;
+ break;
- case GLSL_TYPE_FLOAT:
- for (unsigned i = 0; i < column_type->vector_elements; i++)
- data.f[i] = array->value.f[mat_idx + i];
+ case GLSL_TYPE_FLOAT:
+ for (unsigned i = 0; i < column_type->vector_elements; i++)
+ data.f[i] = array->value.f[mat_idx + i];
- break;
+ break;
- case GLSL_TYPE_DOUBLE:
- for (unsigned i = 0; i < column_type->vector_elements; i++)
- data.d[i] = array->value.d[mat_idx + i];
+ case GLSL_TYPE_DOUBLE:
+ for (unsigned i = 0; i < column_type->vector_elements; i++)
+ data.d[i] = array->value.d[mat_idx + i];
- break;
+ break;
- default:
- assert(!"Should not get here.");
- break;
- }
+ default:
+ assert(!"Should not get here.");
+ break;
+ }
- return new(ctx) ir_constant(column_type, &data);
+ return new(ctx) ir_constant(column_type, &data);
} else if (array->type->is_vector()) {
- const unsigned component = idx->value.u[0];
+ const unsigned component = idx->value.u[0];
- return new(ctx) ir_constant(array, component);
+ return new(ctx) ir_constant(array, component);
} else {
- const unsigned index = idx->value.u[0];
- return array->get_array_element(index)->clone(ctx, NULL);
+ const unsigned index = idx->value.u[0];
+ return array->get_array_element(index)->clone(ctx, NULL);
}
}
return NULL;
@@ -1922,102 +1922,102 @@ ir_call::constant_expression_value(struct hash_table *variable_context)
bool ir_function_signature::constant_expression_evaluate_expression_list(const struct exec_list &body,
- struct hash_table *variable_context,
- ir_constant **result)
+ struct hash_table *variable_context,
+ ir_constant **result)
{
foreach_in_list(ir_instruction, inst, &body) {
switch(inst->ir_type) {
- /* (declare () type symbol) */
+ /* (declare () type symbol) */
case ir_type_variable: {
- ir_variable *var = inst->as_variable();
- hash_table_insert(variable_context, ir_constant::zero(this, var->type), var);
- break;
+ ir_variable *var = inst->as_variable();
+ hash_table_insert(variable_context, ir_constant::zero(this, var->type), var);
+ break;
}
- /* (assign [condition] (write-mask) (ref) (value)) */
+ /* (assign [condition] (write-mask) (ref) (value)) */
case ir_type_assignment: {
- ir_assignment *asg = inst->as_assignment();
- if (asg->condition) {
- ir_constant *cond = asg->condition->constant_expression_value(variable_context);
- if (!cond)
- return false;
- if (!cond->get_bool_component(0))
- break;
- }
+ ir_assignment *asg = inst->as_assignment();
+ if (asg->condition) {
+ ir_constant *cond = asg->condition->constant_expression_value(variable_context);
+ if (!cond)
+ return false;
+ if (!cond->get_bool_component(0))
+ break;
+ }
- ir_constant *store = NULL;
- int offset = 0;
+ ir_constant *store = NULL;
+ int offset = 0;
- if (!constant_referenced(asg->lhs, variable_context, store, offset))
- return false;
+ if (!constant_referenced(asg->lhs, variable_context, store, offset))
+ return false;
- ir_constant *value = asg->rhs->constant_expression_value(variable_context);
+ ir_constant *value = asg->rhs->constant_expression_value(variable_context);
- if (!value)
- return false;
+ if (!value)
+ return false;
- store->copy_masked_offset(value, offset, asg->write_mask);
- break;
+ store->copy_masked_offset(value, offset, asg->write_mask);
+ break;
}
- /* (return (expression)) */
+ /* (return (expression)) */
case ir_type_return:
- assert (result);
- *result = inst->as_return()->value->constant_expression_value(variable_context);
- return *result != NULL;
+ assert (result);
+ *result = inst->as_return()->value->constant_expression_value(variable_context);
+ return *result != NULL;
- /* (call name (ref) (params))*/
+ /* (call name (ref) (params))*/
case ir_type_call: {
- ir_call *call = inst->as_call();
+ ir_call *call = inst->as_call();
- /* Just say no to void functions in constant expressions. We
- * don't need them at that point.
- */
+ /* Just say no to void functions in constant expressions. We
+ * don't need them at that point.
+ */
- if (!call->return_deref)
- return false;
+ if (!call->return_deref)
+ return false;
- ir_constant *store = NULL;
- int offset = 0;
+ ir_constant *store = NULL;
+ int offset = 0;
- if (!constant_referenced(call->return_deref, variable_context,
+ if (!constant_referenced(call->return_deref, variable_context,
store, offset))
- return false;
+ return false;
- ir_constant *value = call->constant_expression_value(variable_context);
+ ir_constant *value = call->constant_expression_value(variable_context);
- if(!value)
- return false;
+ if(!value)
+ return false;
- store->copy_offset(value, offset);
- break;
+ store->copy_offset(value, offset);
+ break;
}
- /* (if condition (then-instructions) (else-instructions)) */
+ /* (if condition (then-instructions) (else-instructions)) */
case ir_type_if: {
- ir_if *iif = inst->as_if();
+ ir_if *iif = inst->as_if();
- ir_constant *cond = iif->condition->constant_expression_value(variable_context);
- if (!cond || !cond->type->is_boolean())
- return false;
+ ir_constant *cond = iif->condition->constant_expression_value(variable_context);
+ if (!cond || !cond->type->is_boolean())
+ return false;
- exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions;
+ exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions;
- *result = NULL;
- if (!constant_expression_evaluate_expression_list(branch, variable_context, result))
- return false;
+ *result = NULL;
+ if (!constant_expression_evaluate_expression_list(branch, variable_context, result))
+ return false;
- /* If there was a return in the branch chosen, drop out now. */
- if (*result)
- return true;
+ /* If there was a return in the branch chosen, drop out now. */
+ if (*result)
+ return true;
- break;
+ break;
}
- /* Every other expression type, we drop out. */
+ /* Every other expression type, we drop out. */
default:
- return false;
+ return false;
}
}
@@ -2056,7 +2056,7 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters, s
* been checked earlier.
*/
hash_table *deref_hash = hash_table_ctor(8, hash_table_pointer_hash,
- hash_table_pointer_compare);
+ hash_table_pointer_compare);
/* If "origin" is non-NULL, then the function body is there. So we
* have to use the variable objects from the object with the body,