Changing the layer of an entity could cause flickering
Only sort the depth list just before rendering.
Merge remote-tracking branch 'upstream/master'