  We count the number of bound states of BPS black holes on local Calabi-Yau
three-folds involving a Riemann surface of genus g. We show that the
corresponding gauge theory on the brane reduces to a q-deformed Yang-Mills
theory on the Riemann surface. Following the recent connection between the
black hole entropy and the topological string partition function, we find that
for a large black hole charge N, up to corrections of $O(e^{-N})$, $Z_{BH}$ is
given as a sum of a square of chiral blocks, each of which corresponds to a
specific D-brane amplitude. The leading chiral block, the vacuum block,
corresponds to the closed topological string amplitudes. The sub-leading chiral
blocks involve topological string amplitudes with D-brane insertions at 2g-2
points on the Riemann surface analogous to the $\Omega$ points in the large N
2d Yang-Mills theory. The finite N amplitude provides a non-perturbative
definition of topological strings in these backgrounds. This also leads to a
novel non-perturbative formulation of c=1 non-critical string at the self-dual
radius.
