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")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
48 jobs for !2320 with fix_implem_error_teximage in 19 minutes and 22 seconds (queued for 5 seconds)
detached
Status Job ID Name Coverage
  Container
passed #754577
debian-10

00:00:21

passed #754578
debian-9

00:00:18

passed #754576
lava-container:arm64

00:00:22

passed #754575
lava-container:armhf

00:00:19

passed #754579
aarch64
test-container:arm64

00:00:19

 
  Build
passed #754581
lava-build:arm64

00:05:13

passed #754580
lava-build:armhf

00:05:13

passed #754584
meson-arm64

00:06:21

passed #754583
meson-armhf

00:04:24

passed #754586
meson-clang

00:08:13

passed #754589
meson-clover

00:07:02

passed #754590
meson-clover-old-llvm

00:04:32

passed #754592
meson-i386

00:05:13

passed #754582
meson-main

00:10:17

passed #754585
meson-swr-glvnd

00:05:58

passed #754591
meson-vulkan

00:03:43

passed #754593
scons

00:10:18

passed #754594
scons-old-llvm

00:08:22

passed #754587
scons-swr

00:06:06

passed #754588
scons-win64

00:07:01

 
  Test
passed #754619
db410c
arm64_a306_gles2 1/4

00:11:37

passed #754620
db410c
arm64_a306_gles2 2/4

00:10:37

passed #754621
db410c
arm64_a306_gles2 3/4

00:08:43

passed #754622
db410c
arm64_a306_gles2 4/4

00:03:44

passed #754608
mesa-cheza
arm64_a630_gles2

00:04:10

passed #754609
mesa-cheza
arm64_a630_gles31 1/4

00:03:48

passed #754610
mesa-cheza
arm64_a630_gles31 2/4

00:04:35

passed #754611
mesa-cheza
arm64_a630_gles31 3/4

00:04:40

passed #754612
mesa-cheza
arm64_a630_gles31 4/4

00:04:31

passed #754613
mesa-cheza
arm64_a630_gles3 1/6

00:03:39

passed #754614
mesa-cheza
arm64_a630_gles3 2/6

00:03:37

passed #754615
mesa-cheza
arm64_a630_gles3 3/6

00:03:24

passed #754616
mesa-cheza
arm64_a630_gles3 4/6

00:03:24

passed #754617
mesa-cheza
arm64_a630_gles3 5/6

00:03:35

passed #754618
mesa-cheza
arm64_a630_gles3 6/6

00:03:24

passed #754598
lava-meson-gxl-s905x-libretech-cc
lima-test:arm64

00:04:46

passed #754597
lava-sun8i-h3-libretech-all-h3-cc
lima-test:armhf

00:05:36

passed #754595
lava-rk3288-veyron-jaq
panfrost-t760-test:armhf

00:05:45

passed #754596
lava-rk3399-gru-kevin
panfrost-t860-test:arm64

00:04:56

passed #754599
test-llvmpipe-gles2 1/4

00:03:18

passed #754600
test-llvmpipe-gles2 2/4

00:04:07

passed #754601
test-llvmpipe-gles2 3/4

00:03:27

passed #754602
test-llvmpipe-gles2 4/4

00:03:50

passed #754603
test-softpipe-gles2 1/4

00:01:29

passed #754604
test-softpipe-gles2 2/4

00:01:41

passed #754605
test-softpipe-gles2 3/4

00:01:38

passed #754606
test-softpipe-gles2 4/4

00:01:32

passed #754607
test-softpipe-gles3-limited

00:02:28