+ array_size = min(array_size, max<size_t>(info.array_size, 1U));
+
+ size_t store_offset;
+ bool packed;
+ if(info.block->bind_point==ReflectData::DEFAULT_BLOCK)
+ {
+ if(info.location<0)
+ return;
+
+ store_offset = info.location*16;
+ packed = true;
+ }
+ else
+ {
+ store_offset = info.offset;
+ if(array_size!=1 && info.array_stride!=get_type_size(info.type))
+ packed = false;
+ else if(is_matrix(info.type))
+ packed = (info.matrix_stride==get_type_size(get_matrix_column_type(info.type)));
+ else
+ packed = true;
+ }
+
+ char *store_ptr = data.data()+store_offset;
+ const char *value_ptr = static_cast<const char *>(value);
+ if(packed)
+ {
+ size_t value_size = array_size*get_type_size(info.type);
+ check_store_range(store_offset, value_size);
+ copy(value_ptr, value_ptr+value_size, store_ptr);
+ }
+ else if(is_matrix(info.type))
+ {
+ unsigned col_size = get_type_size(get_matrix_column_type(info.type));
+ unsigned cols = get_type_size(info.type)/col_size;
+ check_store_range(store_offset, (array_size-1)*info.array_stride+(cols-1)*info.matrix_stride+col_size);
+ for(unsigned i=0; i<array_size; ++i)
+ {
+ char *elem_ptr = store_ptr;
+ for(unsigned j=0; j<cols; ++j)
+ {
+ copy(value_ptr, value_ptr+col_size, elem_ptr);
+ value_ptr += col_size;
+ elem_ptr += info.matrix_stride;
+ }
+ store_ptr += info.array_stride;
+ }
+ }
+ else
+ {
+ unsigned elem_size = get_type_size(info.type);
+ check_store_range(store_offset, (array_size-1)*info.array_stride+elem_size);
+ for(unsigned i=0; i<array_size; ++i)
+ {
+ copy(value_ptr, value_ptr+elem_size, store_ptr);
+ value_ptr += elem_size;
+ store_ptr += info.array_stride;
+ }
+ }
+
+ mark_dirty();