  For various 2-Calabi-Yau categories $\mathscr{C}$ for which the stack of
objects $\mathfrak{M}$ has a good moduli space $p\colon\mathfrak{M}\rightarrow
\mathcal{M}$, we establish purity of the mixed Hodge module complex
$p_{!}\underline{\mathbb{Q}}_{\mathfrak{M}}$. We do this by using formality in
2CY categories, along with \'etale neighbourhood theorems for stacks, to prove
that the morphism $p$ is modelled \'etale-locally by the semisimplification
morphism from the stack of modules of a preprojective algebra. Then via the
integrality theorem in cohomological Donaldson-Thomas theory we prove purity of
$p_{!}\underline{\mathbb{Q}}_{\mathfrak{M}}$. It follows that the
Beilinson-Bernstein-Deligne-Gabber decomposition theorem for the constant sheaf
holds for the morphism $p$, despite the possibly very singular and stacky
nature of $\mathfrak{M}$. We use this to define cuspidal cohomology for
$\mathfrak{M}$, which is conjecturally a complete space of generators for the
BPS algebra associated to $\mathscr{C}$.
  We prove purity of the Borel-Moore homology of the moduli stack
$\mathfrak{M}$, provided its good moduli space $\mathcal{M}$ is projective, or
admits a suitable contracting $\mathbb{C}^*$-action. In particular, when
$\mathfrak{M}$ is the moduli stack of Gieseker-semistable sheaves on a K3
surface, this proves a conjecture of Halpern-Leistner. We use these results to
moreover prove purity for several stacks of coherent sheaves that do not admit
a good moduli space.
  Without the usual assumption that $r$ and $d$ are coprime, we prove that the
Borel-Moore homology of the stack of semistable degree $d$ rank $r$ Higgs
sheaves is pure and carries a perverse filtration with respect to the Hitchin
base, generalising the usual perverse filtration for the Hitchin system to the
case of singular stacks of Higgs sheaves.
