}
static enum mali_format
-pan_format_from_glsl(const struct glsl_type *type)
+pan_format_from_glsl(const struct glsl_type *type, unsigned frac)
{
- enum glsl_base_type glsl_base = glsl_get_base_type(glsl_without_array(type));
+ const struct glsl_type *column = glsl_without_array_or_matrix(type);
+ enum glsl_base_type glsl_base = glsl_get_base_type(column);
nir_alu_type t = nir_get_nir_type_for_glsl_base_type(glsl_base);
+ unsigned chan = glsl_get_components(column);
+
+ /* If we have a fractional location added, we need to increase the size
+ * so it will fit, i.e. a vec3 in YZW requires us to allocate a vec4.
+ * We could do better but this is an edge case as it is, normally
+ * packed varyings will be aligned. */
+ chan += frac;
+
+ assert(chan >= 1 && chan <= 4);
unsigned base = nir_alu_type_get_base_type(t);
unsigned size = nir_alu_type_get_type_size(t);
return pan_format_from_nir_base(base) |
pan_format_from_nir_size(base, size) |
- MALI_NR_CHANNELS(4);
+ MALI_NR_CHANNELS(chan);
}
static enum bifrost_shader_type
for (int c = 0; c < sz; ++c) {
p_varyings[loc + c] = var->data.location + c;
- p_varying_type[loc + c] = pan_format_from_glsl(var->type);
+ p_varying_type[loc + c] = pan_format_from_glsl(var->type, var->data.location_frac);
}
}
* there are.
*/
#define MALI_NR_CHANNELS(n) ((n - 1) << 3)
+#define MALI_EXTRACT_CHANNELS(fmt) ((((fmt) >> 3) & 3) + 1)
/* If the high 3 bits are 3 to 6, then the low 3 bits say how big each
* component is, except the special MALI_CHANNEL_FLOAT which overrides what the