diff options
author | Eric Anholt <eric@anholt.net> | 2010-06-25 17:50:25 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-06-25 18:01:20 -0700 |
commit | 0bef5b97a9eccebc4b59dff42b2863770da770fe (patch) | |
tree | 5e900145b0ae9c9d72ed73d4cd6f78d8c7f18df6 | |
parent | 6152fa16a16c876497ab1791212dc79b15e91c1a (diff) |
glsl2: Add support for non-float constants in Mesa IR.
Fixes glsl-vs-vec4-indexing-4.
-rw-r--r-- | src/mesa/shader/ir_to_mesa.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f28f5fcbfc..99ec55a0d8 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -980,22 +980,41 @@ void ir_to_mesa_visitor::visit(ir_constant *ir) { ir_to_mesa_src_reg src_reg; + GLfloat stack_vals[4]; + GLfloat *values = stack_vals; + unsigned int i; - assert(ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_UINT || - ir->type->base_type == GLSL_TYPE_INT || - ir->type->base_type == GLSL_TYPE_BOOL); - - if (ir->type->base_type == GLSL_TYPE_FLOAT && - !ir->type->is_matrix() && !ir->type->is_array()) { - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = - _mesa_add_unnamed_constant(this->prog->Parameters, - &ir->value.f[0], ir->type->vector_elements, - &src_reg.swizzle); - } else { - assert(!"FINISHME: non-float constants"); + if (ir->type->is_matrix() || ir->type->is_array()) { + assert(!"FINISHME: array/matrix constants"); } + + src_reg.file = PROGRAM_CONSTANT; + switch (ir->type->base_type) { + case GLSL_TYPE_FLOAT: + values = &ir->value.f[0]; + break; + case GLSL_TYPE_UINT: + for (i = 0; i < ir->type->vector_elements; i++) { + values[i] = ir->value.u[i]; + } + break; + case GLSL_TYPE_INT: + for (i = 0; i < ir->type->vector_elements; i++) { + values[i] = ir->value.i[i]; + } + break; + case GLSL_TYPE_BOOL: + for (i = 0; i < ir->type->vector_elements; i++) { + values[i] = ir->value.b[i]; + } + break; + default: + assert(!"Non-float/uint/int/bool constant"); + } + + src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, + values, ir->type->vector_elements, + &src_reg.swizzle); src_reg.reladdr = false; src_reg.negate = 0; |