diff options
author | marha <marha@users.sourceforge.net> | 2012-04-10 10:49:59 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-10 10:49:59 +0200 |
commit | c6f80401dc533b04341afe8d596960d1bc25efce (patch) | |
tree | 2826007946218a8370d2eebc6aa32083618e2bfe /mesalib/src/glsl/ir_constant_expression.cpp | |
parent | 31706e67674f308e3e7f2a8aaf02f1e0a00fbade (diff) | |
download | vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.tar.gz vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.tar.bz2 vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.zip |
fontconfig mesa xkeyboard-config xserver pixman git update 10 Apr 2012
Diffstat (limited to 'mesalib/src/glsl/ir_constant_expression.cpp')
-rw-r--r-- | mesalib/src/glsl/ir_constant_expression.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp index adca62e8d..4e1714a84 100644 --- a/mesalib/src/glsl/ir_constant_expression.cpp +++ b/mesalib/src/glsl/ir_constant_expression.cpp @@ -71,6 +71,13 @@ dot(ir_constant *op0, ir_constant *op1) } ir_constant * +ir_rvalue::constant_expression_value() +{ + assert(this->type->is_error()); + return NULL; +} + +ir_constant * ir_expression::constant_expression_value() { if (this->type->is_error()) @@ -1017,21 +1024,29 @@ ir_constant::constant_expression_value() ir_constant * ir_call::constant_expression_value() { - if (this->type == glsl_type::error_type) + return this->callee->constant_expression_value(&this->actual_parameters); +} + + +ir_constant * +ir_function_signature::constant_expression_value(exec_list *actual_parameters) +{ + const glsl_type *type = this->return_type; + if (type == glsl_type::void_type) return NULL; /* From the GLSL 1.20 spec, page 23: * "Function calls to user-defined functions (non-built-in functions) * cannot be used to form constant expressions." */ - if (!this->callee->is_builtin) + if (!this->is_builtin) return NULL; unsigned num_parameters = 0; /* Check if all parameters are constant */ ir_constant *op[3]; - foreach_list(n, &this->actual_parameters) { + foreach_list(n, actual_parameters) { ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value(); if (constant == NULL) return NULL; @@ -1053,7 +1068,7 @@ ir_call::constant_expression_value() ir_constant_data data; memset(&data, 0, sizeof(data)); - const char *callee = this->callee_name(); + const char *callee = this->function_name(); if (strcmp(callee, "abs") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL); } else if (strcmp(callee, "all") == 0) { @@ -1101,7 +1116,7 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = atanhf(op[0]->value.f[c]); } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { - return ir_constant::zero(mem_ctx, this->type); + return ir_constant::zero(mem_ctx, type); } else if (strcmp(callee, "ceil") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL); } else if (strcmp(callee, "clamp") == 0) { @@ -1192,7 +1207,7 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "fract") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL); } else if (strcmp(callee, "fwidth") == 0) { - return ir_constant::zero(mem_ctx, this->type); + return ir_constant::zero(mem_ctx, type); } else if (strcmp(callee, "greaterThan") == 0) { assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); for (unsigned c = 0; c < op[0]->type->components(); c++) { @@ -1298,7 +1313,7 @@ ir_call::constant_expression_value() float length = sqrtf(dot(op[0], op[0])); if (length == 0) - return ir_constant::zero(mem_ctx, this->type); + return ir_constant::zero(mem_ctx, type); for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = op[0]->value.f[c] / length; @@ -1349,7 +1364,7 @@ ir_call::constant_expression_value() const float dot_NI = dot(op[1], op[0]); const float k = 1.0F - eta * eta * (1.0F - dot_NI * dot_NI); if (k < 0.0) { - return ir_constant::zero(mem_ctx, this->type); + return ir_constant::zero(mem_ctx, type); } else { for (unsigned c = 0; c < type->components(); c++) { data.f[c] = eta * op[0]->value.f[c] - (eta * dot_NI + sqrtf(k)) @@ -1418,5 +1433,5 @@ ir_call::constant_expression_value() if (expr != NULL) return expr->constant_expression_value(); - return new(mem_ctx) ir_constant(this->type, &data); + return new(mem_ctx) ir_constant(type, &data); } |