A Coral polyp is an animal, it consumes food, does not require light and so does not have to live near the surface. However they are able to be shallow-water reef builders, and food suppliers for fish, because of tiny symbiotic algae called zooxanthellae, which live inside the polyp.
These algae convert by photosynthesis, dissolved seawater carbon and phosphate into oxygen and various food stuffs like sugar and amino acids. The polyp is able to use the foodstuffs and in so doing excrete its waste products of Carbon dioxide and ammonia. The algae in turn utilises these and produces fresh supplies of oxygen.
The algae need light for photosynthesis, hence the best diving is to be had from about 30m and up where the food chain is most prolific.
The algae also help the conversion of calcium (from sea water) and carbon dioxide (from the polyp) to Calcium carbonate (limestone) which is the principal ingredient of the coral reef.
Just some fun pic's of coral gardens.
Any better ones please feel free to upload. Ref: x