st/mesa: fix corrupted texture levels, when adding more levels than expected
Some of existing texture levels can be corruted, after calling 'glTexImage' with param 'level' higher than max expected value 'floor(log2(max(width, height, depth)))'.
To fix we prevent overwriting image buffer pointer in 'st_texture_object', if it was already allocated for multiple mip-levels storage.
Asked OpenGL on github, what behavior is expected in this case, since it not specified in spec. Waiting for their response at https://github.com/KhronosGroup/OpenGL-API/issues/71 .
Also after applying this fix we got same behavior as on NVidia GPU: read garbage data from additional levels, but perfectly correct data from legal levels. Test results on Nvidia, Windows, with 7 levels on 32x32 texture uploaded here: https://gist.github.com/DenKos363/cee8d0f6a171def0be8cfd3ac668be2d
Signed-off-by: Yevhenii Kharchenko yevhenii.kharchenko@globallogic.com
Fixes piglit test: 'arb_copy_image add-illegal-levels' Merge request of this piglit test piglit!313 (merged)
Passes Intel CI: https://mesa-ci.01.org/global_logic/builds/275/group/63a9f0ea7bb98050796b649e85481845