summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_varyings.cpp
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2012-12-18 16:37:52 -0800
committerPaul Berry <[email protected]>2013-01-08 09:18:14 -0800
commitc35abcd1b0d0e0059c60781bd21558872020553d (patch)
tree6d6b0dde5c04f96ee075a75e4a7819dbdf0580f6 /src/glsl/link_varyings.cpp
parent18720555dd2da779ad6907e8f6aa083e7b4d1841 (diff)
glsl: Pack flat "varyings" of mixed types together.
This patch enhances the varying packing code so that flat varyings of uint, int, and float types can be packed together. We accomplish this in lower_packed_varyings.cpp by making the type of all flat varyings ivec4, and then using information-preserving type conversions (e.g. ir_unop_bitcast_f2i) to convert all other types to ints. The varying_matches::compute_packing_class() function is updated to reflect the fact that varying packing no longer needs to segregate varyings of different base types. Fixes piglit test varying-packing-mixed-types. Reviewed-by: Kenneth Graunke <[email protected]> v2: Split lower_packed_varyings_visitor::bitwise_assign into pack/unpack variants.
Diffstat (limited to 'src/glsl/link_varyings.cpp')
-rw-r--r--src/glsl/link_varyings.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index b9c3f5d434d..5c27f231e72 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -777,17 +777,25 @@ varying_matches::store_locations(unsigned producer_base,
unsigned
varying_matches::compute_packing_class(ir_variable *var)
{
- /* In this initial implementation we conservatively assume that variables
- * can only be packed if their base type (float/int/uint/bool) matches and
- * their interpolation and centroid qualifiers match.
+ /* Without help from the back-end, there is no way to pack together
+ * variables with different interpolation types, because
+ * lower_packed_varyings must choose exactly one interpolation type for
+ * each packed varying it creates.
*
- * TODO: relax these restrictions when the driver back-end permits.
+ * However, we can safely pack together floats, ints, and uints, because:
+ *
+ * - varyings of base type "int" and "uint" must use the "flat"
+ * interpolation type, which can only occur in GLSL 1.30 and above.
+ *
+ * - On platforms that support GLSL 1.30 and above, lower_packed_varyings
+ * can store flat floats as ints without losing any information (using
+ * the ir_unop_bitcast_* opcodes).
+ *
+ * Therefore, the packing class depends only on the interpolation type.
*/
unsigned packing_class = var->centroid ? 1 : 0;
packing_class *= 4;
packing_class += var->interpolation;
- packing_class *= GLSL_TYPE_ERROR;
- packing_class += var->type->get_scalar_type()->base_type;
return packing_class;
}