  We use the energy-balance code MAGPHYS to determine stellar and dust masses,
and dust corrected star-formation rates for over 200,000 GAMA galaxies, 170,000
G10-COSMOS galaxies and 200,000 3D-HST galaxies. Our values agree well with
previously reported measurements and constitute a representative and
homogeneous dataset spanning a broad range in stellar mass (10^8---10^12 Msol),
dust mass (10^6---10^9 Msol), and star-formation rates (0.01---100 Msol per
yr), and over a broad redshift range (0.0 < z < 5.0). We combine these data to
measure the cosmic star-formation history (CSFH), the stellar-mass density
(SMD), and the dust-mass density (DMD) over a 12 Gyr timeline. The data mostly
agree with previous estimates, where they exist, and provide a
quasi-homogeneous dataset using consistent mass and star-formation estimators
with consistent underlying assumptions over the full time range. As a
consequence our formal errors are significantly reduced when compared to the
historic literature. Integrating our cosmic star-formation history we precisely
reproduce the stellar-mass density with an ISM replenishment factor of 0.50 +/-
0.07, consistent with our choice of Chabrier IMF plus some modest amount of
stripped stellar mass. Exploring the cosmic dust density evolution, we find a
gradual increase in dust density with lookback time. We build a simple
phenomenological model from the CSFH to account for the dust mass evolution,
and infer two key conclusions: (1) For every unit of stellar mass which is
formed 0.0065---0.004 units of dust mass is also formed; (2) Over the history
of the Universe approximately 90 to 95 per cent of all dust formed has been
destroyed and/or ejected.
