To start off this topic, here’s a useful survey of the evolution of the brain.
Of course the author has only the conventional view of stimuli, plans, etc., and it is for us to enquire about control systems and levels of perception in these several stages of evolution.
Fascinating, for example, that some evolutionary biologists propose that the rudimentary eye (exemplified by the ragworm) evolved first, and that the richness of sensory input from light was the occasion for the development of the brain by reorganization (as we would put it) .