st/mesa: Allocate full miplevels if MaxLevel is explicitly set
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 15 Jan 2020 00:25:11 +0000 (16:25 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 16 Jan 2020 08:06:54 +0000 (00:06 -0800)
commite3405f177bdff591423e1fe154defba10d326d55
tree8ad51ec36384ad9b0065a0e709fb791c1da2c7d9
parent68abc0731715b2ec3048d0944250b96a5302b4bc
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 <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3401>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3401>
src/mesa/state_tracker/st_cb_texture.c