st/mesa: Allocate full miplevels if MaxLevel is explicitly set

Some applications explicitly call glTex[ture]Parameteri[v] to set
GL_TEXTURE_MAX_LEVEL and GL_TEXTURE_BASE_LEVEL before uploading any
texture data.  Core Mesa initializes MaxLevel to 1000, so if it isn't
that, we know they've set it.  (We check for < TEXTURE_MAX_LEVELS to
avoid hardcoding that value, however.)

If MaxLevel - BaseLevel > 0, then the app is trying to tell us that
this texture is going to have multiple miplevels.  In that case, go
ahead and allocate the space for it.

Avoids many resource_copy_region calls at texture finalization time
in the Civilization VI benchmark.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Marge Bot <mesa/mesa!3401>
Part-of: <mesa/mesa!3401>
37 jobs for !3401 with civ-mipmap in 33 minutes and 1 second (queued for 6 seconds)
detached
Status Job ID Name Coverage
  Container
passed #1374907
aarch64
arm_build

00:00:18

passed #1374908
aarch64
arm_test

00:00:18

passed #1374904
x86_build

00:00:23

passed #1374906
x86_build_old

00:00:18

passed #1374905
x86_test-gl

00:00:25

 
  Build
passed #1374912
aarch64
meson-arm64

00:03:09

passed #1374911
aarch64
meson-armhf

00:10:51

passed #1374913
meson-clang

00:08:24

passed #1374916
meson-clover

00:10:05

passed #1374917
meson-clover-old-llvm

00:06:11

passed #1374919
meson-i386

00:05:01

passed #1374910
meson-main

00:03:44

passed #1374920
meson-mingw32-x86_64

00:04:38

passed #1374909
meson-testing

00:06:15

passed #1374918
meson-vulkan

00:04:00

passed #1374921
scons

00:05:59

passed #1374922
scons-old-llvm

00:02:50

passed #1374914
scons-swr

00:10:56

passed #1374915
scons-win64

00:05:36

 
  Test
passed #1374940
db410c
arm64_a306_gles2

00:06:07

passed #1374937
mesa-cheza
arm64_a630_gles2

00:02:02

passed #1374939
mesa-cheza
arm64_a630_gles3

00:06:35

passed #1374938
mesa-cheza
arm64_a630_gles31

00:04:28

passed #1374923
lava-sun50i-h6-pine-h64
panfrost-t720-test:arm64

00:10:39

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

00:05:53

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

00:08:16

passed #1374927
piglit-glslparser

00:04:37

passed #1374926
piglit-quick_gl

00:09:41

passed #1374928
piglit-quick_shader

00:06:01

passed #1374929
test-llvmpipe-gles2

00:04:14

passed #1374930
test-softpipe-gles2

00:01:19

passed #1374933
test-softpipe-gles31 1/4

00:03:00

passed #1374931
test-softpipe-gles3 1/2

00:08:22

passed #1374934
test-softpipe-gles31 2/4

00:03:15

passed #1374935
test-softpipe-gles31 3/4

00:08:42

passed #1374936
test-softpipe-gles31 4/4

00:02:18

passed #1374932
test-softpipe-gles3 2/2

00:04:11