The concept would be crystallization. As magma cools inside or outside of the earth it crystallizes into an igneous rock. Intrusive (formed inside crust) igneous rocks are typically more course grained and contain many different noticeable minerals (for example, granite). Extrusive (formed outside) igneous rocks are typically more porous and are more fine grained then intrusive rocks (example, obsidian).
Photosynthesis is 6 CO2 + 6H2O---> C6H12O6 + 6 O2. So unless I understand the question wrong, none is needed to do, but glucose and oxygen are products after the photosynthesis