ir3_compiler/nir: fix imageSize() for buffer-backed images
authorEduardo Lima Mitev <elima@igalia.com>
Tue, 23 Oct 2018 19:24:11 +0000 (21:24 +0200)
committerEduardo Lima Mitev <elima@igalia.com>
Wed, 24 Oct 2018 16:18:35 +0000 (18:18 +0200)
commitb0c427043bc01dde32e91893f2fb881e9bd99967
tree203c75ef73bb54f57e94f4ac26a97eadb8387676
parentd9a04196d9b3919ed216842510606654eb64222d
ir3_compiler/nir: fix imageSize() for buffer-backed images

GL_EXT_texture_buffer introduced texture buffers, which can be used
in shaders through a new type imageBuffer.

Because how image access is implemented in freedreno, calling
imageSize on an imageBuffer returns the size in bytes instead of texels,
which is incorrect.

This patch adds a division of imageSize result by the bytes-per-pixel
of the image format, when image is buffer-backed.

Fixes all tests under
dEQP-GLES31.functional.image_load_store.buffer.image_size.*

v2: Pre-compute and submit the log2 of the image format's bpp as shader
    constant instead of emitting the LOG2 instruction in code. (Rob Clark)

v3: Use ffs (find-first-bit) helper for computing log2 (Ilia Mirkin)

Reviewed-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/ir3/ir3_shader.c