[Mesa-dev] [PATCH v3 12/29] glsl/ir: Add builtin constant function support for doubles
Matt Turner
mattst88 at gmail.com
Sun Feb 8 11:29:18 PST 2015
On Sun, Feb 8, 2015 at 1:00 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> @@ -667,32 +679,81 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
> data.b[0] = true;
> }
> break;
> -
> - case ir_unop_trunc:
> + 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];
> + }
> + 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.f[c] = truncf(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];
> + }
> + 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];
> + }
> + 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];
> + }
> + 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];
> + }
> + break;
> + case ir_unop_d2b:
> + assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
> + for (unsigned c = 0; c < op[0]->type->components(); c++) {
> + data.b[c] = op[0]->value.d[c] != 0.0 ? true : false;
? true : false is a nop.
More information about the mesa-dev
mailing list