iris: fix layer calculation for TEXTURE_3D ReadPixels() on mip-level>0

Fixes assert when ReadPixels() called to read from FBO to
GL_PIXEL_PACK_BUFFER, on mip-level > 0, since num_layers
wasn't properly calculated with mip-level.

The logic of fix is similar to one used in 'brw_predraw_resolve_inputs'
function of i965 driver, which is called in a same circumstances.

Fixes: 3c979b0e ('iris: add some draw resolve hooks')

Signed-off-by: Yevhenii Kharchenko <>
35 jobs for !25 with fix/iris-3d-texture-layers-num in 8 seconds (queued for 3 seconds)
latest merge request