  The growing population of binary black holes (BBHs) observed by gravitational
wave detectors is a potential Rosetta stone for understanding their formation
channels. Here, we use an upgraded version of our semi-analytic codes {\sc
fastcluster} and {\sc cosmo$\mathcal{R}$ate} to investigate the cosmic
evolution of four different BBH populations: isolated BBHs and dynamically
formed BBHs in nuclear star clusters (NSCs), globular clusters (GCs), and young
star clusters (YSCs). With our approach, we can study different channels
assuming the same stellar and binary input physics. We find that the merger
rate density of BBHs in GCs and NSCs is barely affected by stellar metallicity
($Z$), while the rate of isolated BBHs changes wildly with $Z$. BBHs in YSCs
behave in an intermediate way between isolated and GC/NSC BBHs. The local
merger rate density of Nth-generation black holes (BHs), obtained by summing up
hierarchical mergers in GCs, NSCs and YSCs, ranges from $\sim{1}$ to $\sim{4}$
Gpc$^{-3}$ yr$^{-1}$ and is mostly sensitive to the spin parameter. We find
that the mass function of primary BHs evolves with redshift in GCs and NSCs,
becoming more top-heavy at higher $z$. In contrast, the primary BH mass
function almost does not change with redshift in YSCs and in the field. This
signature of the BH mass function has relevant implications for Einstein
Telescope and Cosmic Explorer. Finally, our analysis suggests that multiple
channels contribute to the BBH population of the second gravitational-wave
transient catalog.
