mesa: fix invalid target error handling for teximage
This commit moves the target check before using _mesa_get_current_tex_object to fix a "Mesa implementation error: bad target in _mesa_get_current_tex_object()" error.
Fixes: 9dd1f7ce ("mesa: pass gl_texture_object as arg to not depend on state")