The transformation of chemical or solar energy to biomass. Most primary production occurs through photosynthesis, whereby green plants convert solar energy, carbon dioxide, and water to glucose and eventually to plant tissue. In addition, some bacteria in the deep sea can convert chemical energy to biomass through chemosynthesis.