Despite its important geophysical implications, direct probing of the local electronic structure of mantle minerals, such as MgSiO3 perovskite and post-perovskite is experimentally challenging. Recent advances in ab initio calculations have allowed us to explore the details of the local electronic bonding structure around oxygen in MgSiO3 polymorphs in Earth’s interior. Here, we calculate the O K-edge energy-loss near-edge structure (ELNES) spectra for SiO2 and MgSiO3 polymorphs (i.e., α-quartz, stishovite, enstatite, ilmenite-type MgSiO3, MgSiO3 perovskite, and post-perovskite) using ab initio calculations based on the full-potential linearized planewave (FP-LAPW) method. The calculated O K-edge ELNES spectra for SiO2 and MgSiO3 polymorphs show characteristic oxygen K-edge features caused by distinctive local atomic configurations and topology around oxygen, and are in good agreement with previous experimental O K-edge X-ray Raman scattering (XRS) results. The O K-edge ELNES spectra for α-quartz and enstatite show similar edge features at ~538 eV, which is characteristic of corner-sharing oxygen sites ([4]Si-O-[4]Si). The spectra for stishovite and ilmenite-type MgSiO3 show edge features with double peaks at ~537–538 and ~541–543 eV due to an electronic excitation from an oxygen in edge-sharing topology. The spectrum for MgSiO3 perovskite shows a broad peak spanning from ~538 to ~543 eV, which results from corner-sharing oxygen with two six-coordinated silicon ([6]Si-O-[6]Si). The calculated O K-edge ELNES spectrum for MgSiO3 post-perovskite shows a predicted main feature at ~543–545 eV, approximately 3 eV higher than that of MgSiO3 perovskite. These O K-edge features systematically shift to higher energy with increasing degree of densification in atomic arrangement in the polymorphs (from enstatite, ilmenite, perovskite, to post-perovskite), indicating an increase in the energy of unoccupied oxygen 2p-state with pressure. The calculated O K-edge spectra also show the effect of densification on the changes in the edge features for the crystallographically distinct oxygen sites: the features for the corner-sharing oxygen move to higher energy from enstatite, perovskite, to post-perovskite. A drastic peak shift for edge-sharing O atoms in ilmenite-MgSiO3 and post-perovskite is also observed. These results confirm that the oxygen K-edge features at ~540–550 eV for MgSiO3 glass at pressures above ~20 GPa can be due to densification of the atomic configurations around oxygen in melt networks associated with enhanced proximity between oxygen atoms. The current methods also shed light on a unique opportunity to probe the pressure-induced electronic bonding transitions and topology in diverse simple and complex oxides in Earth’s interior using ab initio calculations of O K-edge ELNES spectra.