  Recently, a universal formula for a non-holomorphic modular completion of the
generating functions of refined BPS indices in various theories with $N=2$
supersymmetry has been suggested. It expresses the completion through the
holomorphic generating functions of lower ranks. Here we show that for $U(N)$
Vafa-Witten theory on Hirzebruch and del Pezzo surfaces this formula can be
used to extract the holomorphic functions themselves, thereby providing the
Betti numbers of instanton moduli spaces on such surfaces. As a result, we
derive a closed formula for the generating functions and their completions for
all $N$. Besides, our construction reveals in a simple way instances of
fiber-base duality, which can be used to derive new non-trivial identities for
generalized Appell functions. It also suggests the existence of new invariants,
whose meaning however remains obscure.
