The spatial photonic Ising machine has achieved remarkable advancements in solving combinatorial optimization problems. However, it still remains a huge challenge to flexibly map an arbitrary problem to the Ising model. In this paper, we propose a general spatial photonic Ising machine based on the interaction matrix eigendecomposition method. The arbitrary interaction matrix can be configured in the two-dimensional Fourier transformation based spatial photonic Ising model by using values generated by matrix eigendecomposition. The error in the structural representation of the Hamiltonian decreases substantially with the growing number of eigenvalues utilized to form the Ising machine. In combination with the optimization algorithm, as low as ∼65% of the eigenvalues are required by intensity modulation to guarantee the best probability of optimal solution for a 20-vertex graph Max-cut problem, and this percentage decreases to below ∼20% for near-zero probability. The 4-spin experiments and error analysis demonstrate the Hamiltonian linear mapping and ergodic optimization. Our work provides a viable approach for spatial photonic Ising machines to solve arbitrary combinatorial optimization problems with the help of the multi-dimensional optical property.