summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-01-11 12:56:03 -0800
committerPaul Berry <[email protected]>2013-01-24 16:30:40 -0800
commit88e4bfde2639568fabde6f5342e305e5689c6a27 (patch)
tree60a05ee2e8ccdbb100f33c312010d9acea7b7fe3 /src
parent3680864c0b2ed4019b952c067205ca16b652cd93 (diff)
glsl: Generalize compute_packing_order for varying structs.
This patch paves the way for allowing varying structs by generalizing varying_matches::compute_packing_order to handle any type of varying. Previously, we packed in the order (vec4, vec2, float, vec3), with matrices being packed according to the size of their columns. Now, we pack everything according to its number of components mod 4, in the order (0, 2, 1, 3). There is no behavioural change for vectors. Matrices are now packed slightly differently: - mat2x2 gets assigned PACKING_ORDER_VEC4 instead of PACKING_ORDER_VEC2. This is slightly better, because it guarantees that the matrix occupies a single varying slot. - mat2x3 gets assigned PACKING_ORDER_VEC2 instead of PACKING_ORDER_VEC3. This is kind of a wash. Previously, mat2x3 had a 25% chance of having neither of its columns double parked, a 50% chance of having exactly one of its columns double parked, and a 25% chance of having both of its columns double parked. Now it always has exactly one of its columns double parked. - mat3x3 gets assigned PACKING_ORDER_SCALAR instead of PACKING_ORDER_VEC3. This doesn't affect much, since in both cases there is no guarantee of how the matrix will be aligned. - mat4x2 gets assigned PACKING_ORDER_VEC4 instead of PACKING_ORDER_VEC2. This is slightly better for the same reason as in mat2x2. - mat4x3 gets assigned PACKING_ORDER_VEC4 instead of PACKING_ORDER_VEC3. This is slightly better for the same reason as in mat2x2. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/link_varyings.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 5a3240b9f71..d8f501cfd8b 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -804,16 +804,15 @@ varying_matches::compute_packing_order(ir_variable *var)
{
const glsl_type *element_type = var->type;
- /* FINISHME: Support for "varying" records in GLSL 1.50. */
while (element_type->base_type == GLSL_TYPE_ARRAY) {
element_type = element_type->fields.array;
}
- switch (element_type->vector_elements) {
+ switch (element_type->component_slots() % 4) {
case 1: return PACKING_ORDER_SCALAR;
case 2: return PACKING_ORDER_VEC2;
case 3: return PACKING_ORDER_VEC3;
- case 4: return PACKING_ORDER_VEC4;
+ case 0: return PACKING_ORDER_VEC4;
default:
assert(!"Unexpected value of vector_elements");
return PACKING_ORDER_VEC4;