st/mesa: find proper mipmap level in st_ClearTexSubImage()
The Piglit arb_clear_texture-error test creates a texture with only
a 1x1 image at level=1, then tries to clear level 0 (nonexistent)
and level 1 (exists). The test only checks that the former generates
an error but the later doesn't. The test passes, but when we try
to clear the level=1 image we're passing an invalid level to
pipe_context::clear_texture(). level=1, but since there's only one
mipmap level in the texture, it should be zero.
This fixes the code to search the gallium texture resource for the
correct mipmap level. Also, add an assertion to make sure we're not
passing an invalid level to pipe_context::clear_texture().
Fixes device errors with VMware driver. No Piglit regressions.
v2: don't do the level search when using immutable textures.
Reviewed-by: Charmaine Lee <charmainel@vmware.com>