And a whole lot of time, temperature, and pressure driven through geological processes.
Energy from gravity and radiation are contributing factors to fossil fuel production, even if the hydrocarbons broken down for use are largely photosynthetic in nature/origin, they owe their energy density that makes them a viable fuel source to factors beyond solar. Breaking that down has side effects beyond pure photosynthetic processes.