From 11d6f1c69871d0b7edc28f639256460839fccd2d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 16 Nov 2010 12:01:42 -0800 Subject: glsl: Add ir_quadop_vector expression The vector operator collects 2, 3, or 4 scalar components into a vector. Doing this has several advantages. First, it will make ud-chain tracking for components of vectors much easier. Second, a later optimization pass could collect scalars into vectors to allow generation of SWZ instructions (or similar as operands to other instructions on R200 and i915). It also enables an easy way to generate IR for SWZ instructions in the ARB_vertex_program assembler. --- src/glsl/ir_constant_expression.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/glsl/ir_constant_expression.cpp') diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 1fe1505047..4fd6d09a3a 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -788,6 +788,24 @@ ir_expression::constant_expression_value() } break; + 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; + default: + assert(0); + } + } + break; + default: /* FINISHME: Should handle all expression types. */ return NULL; -- cgit v1.2.3