A two-dimensionally programmable photonic chip for classical and quantum information processing