Depth perception is primarily due to binocular vision - the use of two eyes that see at slightly different angles. All predators have binocular vision so that they can pounce/strike accurately. OTOH, most prey species have eyes situate on opposite sides for better threat detection.
See Wikipedia article on stereo vision.
As already pointed out, the optic nerve/brain does a lot of image processing in order to draw conclusions. Relative size is used when other cues are missing. Thus the moon simes to be larger near the earth's horizon than when high in the sky, though if you measure it objectively it willhave the same angular diameter.