[Mesa-dev] [PATCH 06.1] i965: Make brw_type_for_base_type return the element type for arrays.

Kenneth Graunke kenneth at whitecape.org
Tue Nov 8 19:26:38 PST 2011

From: Eric Anholt <eric at anholt.net>

Previously, brw_type_for_base_type returned UD for array variables,
similar to structures.  For structures, each field may have a different
type, so every field access must explicitly override the register's type
with that field's type.  We chose to return UD in this case since it was
the least common, so errors would be more obvious.

For arrays, it makes far more sense to return the type corresponding to
an element of the array.  This allows normal array access to work
without the hassle of explicitly overriding the register's type.

This should obsolete a bunch of type overrides throughout the code.

Signed-off-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
 src/mesa/drivers/dri/i965/brw_shader.cpp |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

(Feel free to change my Signed-off-by to a Reviewed-by if you prefer.)

diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 7679b6e..f25fab3 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -170,6 +170,7 @@ brw_type_for_base_type(const struct glsl_type *type)
    case GLSL_TYPE_UINT:
       return BRW_REGISTER_TYPE_UD;
+      return brw_type_for_base_type(type->fields.array);
       /* These should be overridden with the type of the member when

More information about the mesa-dev mailing list