if (locations[idx][var->data.index] == -1) {
var->data.driver_location = location;
locations[idx][var->data.index] = location;
+
+ /* A dvec3 can be packed with a double we need special handling
+ * for this as we are packing across two locations.
+ */
+ if (glsl_get_base_type(var->type) == GLSL_TYPE_DOUBLE &&
+ glsl_get_vector_elements(var->type) == 3) {
+ /* Hack around type_size functions that expect vectors to be
+ * padded out to vec4. If a float type is the same size as a
+ * double then the type size is padded to vec4, otherwise
+ * set the offset to two doubles which offsets the location
+ * past the first two components in dvec3 which were stored at
+ * the previous location.
+ */
+ unsigned dsize = type_size(glsl_double_type());
+ unsigned offset =
+ dsize == type_size(glsl_float_type()) ? dsize : dsize * 2;
+
+ locations[idx + 1][var->data.index] = location + offset;
+ }
+
location += type_size(var->type);
} else {
var->data.driver_location = locations[idx][var->data.index];