Mesa (glsl2): ir_to_mesa: Fix indexes of temps used in expressions.
Eric Anholt
anholt at kemper.freedesktop.org
Mon Jun 28 20:30:14 UTC 2010
Module: Mesa
Branch: glsl2
Commit: d5a5df45a4af93bb845483bdeeae7c8e042b03d8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5a5df45a4af93bb845483bdeeae7c8e042b03d8
Author: Eric Anholt <eric at anholt.net>
Date: Mon Jun 28 12:48:47 2010 -0700
ir_to_mesa: Fix indexes of temps used in expressions.
It looks like I managed to horribly mangle this in some rebase of the
branch. Fixes:
glsl-fs-fragcoord
glsl-fs-mix
---
src/mesa/shader/ir_to_mesa.cpp | 59 ++++++++++++++++++++-------------------
1 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 90684ad..9cf7839 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -385,35 +385,6 @@ ir_to_mesa_visitor::src_reg_for_float(float val)
return src_reg;
}
-/**
- * In the initial pass of codegen, we assign temporary numbers to
- * intermediate results. (not SSA -- variable assignments will reuse
- * storage). Actual register allocation for the Mesa VM occurs in a
- * pass over the Mesa IR later.
- */
-ir_to_mesa_src_reg
-ir_to_mesa_visitor::get_temp(const glsl_type *type)
-{
- ir_to_mesa_src_reg src_reg;
- int swizzle[4];
- int i;
-
- assert(!type->is_array());
-
- src_reg.file = PROGRAM_TEMPORARY;
- src_reg.index = type->matrix_columns;
- src_reg.reladdr = false;
-
- for (i = 0; i < type->vector_elements; i++)
- swizzle[i] = i;
- for (; i < 4; i++)
- swizzle[i] = type->vector_elements - 1;
- src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1],
- swizzle[2], swizzle[3]);
-
- return src_reg;
-}
-
static int
type_size(const struct glsl_type *type)
{
@@ -448,6 +419,36 @@ type_size(const struct glsl_type *type)
}
}
+/**
+ * In the initial pass of codegen, we assign temporary numbers to
+ * intermediate results. (not SSA -- variable assignments will reuse
+ * storage). Actual register allocation for the Mesa VM occurs in a
+ * pass over the Mesa IR later.
+ */
+ir_to_mesa_src_reg
+ir_to_mesa_visitor::get_temp(const glsl_type *type)
+{
+ ir_to_mesa_src_reg src_reg;
+ int swizzle[4];
+ int i;
+
+ assert(!type->is_array());
+
+ src_reg.file = PROGRAM_TEMPORARY;
+ src_reg.index = next_temp;
+ src_reg.reladdr = false;
+ next_temp += type_size(type);
+
+ for (i = 0; i < type->vector_elements; i++)
+ swizzle[i] = i;
+ for (; i < 4; i++)
+ swizzle[i] = type->vector_elements - 1;
+ src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1],
+ swizzle[2], swizzle[3]);
+
+ return src_reg;
+}
+
temp_entry *
ir_to_mesa_visitor::find_variable_storage(ir_variable *var)
{
More information about the mesa-commit
mailing list