gallium/osmesa: Fix flushing and Y-flipping of the depth buffer.

We were returning a pointer to use-after-free the depth buffer, not
updating it in after future rendering, and also not y flipping it.  A
little refactor to mostly reuse the color buffer's path makes it easy to
do it all right.

Adds a unit test to check for these bugs.

Closes: #885
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7886>
2 files changed