We use the combination of high-resolution electron microscopy and density-functional theory to study the atomic structure and electronic effects of grain boundaries in polycrystalline photovoltaic materials such as Si, CdTe, CuInSe2, and CuGaSe2. We find that grain boundaries containing dislocation cores create deep levels in Si, CdTe, and CuGaSe2. Surprisingly, however, they do not create deep...