A semiconductor device includes a substrate, a semiconductor layer formed
on the substrate, and an optically functional portion formed by using at
least a portion of the semiconductor layer. The optically functional
portion performs light emission or light reception. The semiconductor
device further includes a first driving electrode that is electrically
connected to a semiconductor layer on a surface of the optically
functional portion, and the first driving electrode drives the optically
functional portion. The semiconductor device further includes an
encapsulating electrode that is formed on the semiconductor layer to
surround periphery of the optically functional portion, and electrically
connected to the first driving electrode.