summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-06-25 12:59:10 -0700
committerEric Anholt <eric@anholt.net>2010-06-25 13:27:57 -0700
commit582b73fe691ef7ea12a002cb2ae57505c3b1c21e (patch)
tree151e626b468ad389a5685d433742851ab806e607 /src/mesa
parentffc845a50a69b48446f5e25e7b4485089231bbe7 (diff)
glsl2: Hook up constant parameters in ir_to_mesa.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/ir_to_mesa.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 465d5529f8..accd151576 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -56,7 +56,7 @@ extern "C" {
typedef struct ir_to_mesa_src_reg {
int file; /**< PROGRAM_* from Mesa */
int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */
- int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */
+ GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */
int negate; /**< NEGATE_XYZW mask from mesa */
bool reladdr; /**< Register index should be offset by address reg. */
} ir_to_mesa_src_reg;
@@ -319,14 +319,14 @@ ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir,
* dst channels.
*/
for (i = 0; i < 4; i++) {
- int this_mask = (1 << i);
+ GLuint this_mask = (1 << i);
ir_to_mesa_instruction *inst;
ir_to_mesa_src_reg src = src0;
if (done_mask & this_mask)
continue;
- int src_swiz = GET_SWZ(src.swizzle, i);
+ GLuint src_swiz = GET_SWZ(src.swizzle, i);
for (j = i + 1; j < 4; j++) {
if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) {
this_mask |= (1 << j);
@@ -348,15 +348,9 @@ ir_to_mesa_visitor::src_reg_for_float(float val)
{
ir_to_mesa_src_reg src_reg;
- /* FINISHME: This will end up being _mesa_add_unnamed_constant,
- * which handles sharing values and sharing channels of vec4
- * constants for small values.
- */
- /* FINISHME: Do something with the constant values for now.
- */
- (void)val;
src_reg.file = PROGRAM_CONSTANT;
- src_reg.index = this->next_constant++;
+ src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters,
+ &val, 1, &src_reg.swizzle);
src_reg.swizzle = SWIZZLE_NOOP;
return src_reg;
@@ -985,15 +979,17 @@ ir_to_mesa_visitor::visit(ir_constant *ir)
ir->type->base_type == GLSL_TYPE_INT ||
ir->type->base_type == GLSL_TYPE_BOOL);
- /* FINISHME: This will end up being _mesa_add_unnamed_constant,
- * which handles sharing values and sharing channels of vec4
- * constants for small values.
- */
- /* FINISHME: Do something with the constant values for now.
- */
- src_reg.file = PROGRAM_CONSTANT;
- src_reg.index = this->next_constant;
- src_reg.swizzle = SWIZZLE_NOOP;
+ 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);
+ src_reg.swizzle = SWIZZLE_NOOP;
+ } else {
+ assert(!"FINISHME: non-float constants");
+ }
src_reg.reladdr = false;
src_reg.negate = 0;