mesa: Add helper function _mesa_is_format_integer()

This function will be used in the following patch.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
mesa: Add error condition for integer formats in glGetTexImage()

OpenGL 4.0 spec, page 306 suggests an INVALID_OPERATION in glGetTexImage
if :
   "format is one of the integer formats in table 3.3 and the internal
    format of the texture image is not integer, or format is not one of
    the integer formats in table 3.3 and the internal format is integer."

V2: Use helper function _mesa_is_format_integer()

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
i965: Fix crash in do_blit_readpixels()

Fixes a crash in Khronos CTS packed_pixels tests.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Add missing types in _mesa_texstore_xx_xx() functions

Depth-stencil teture targets are allowed to use source data of type
GL_UNSIGNED_INT_24_8_EXT and GL_FLOAT_32_UNSIGNED_INT_24_8_REV.

Fixes few crashes in Khronos OpenGL CTS packed_pixels tests.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Allow srcFormat=GL_DEPTH_STENCIL in _mesa_texstore_xx_xx() functions

_mesa_texstore_z24_s8() and _mesa_texstore_z32f_x24s8() are capable of
handling GL_DEPTH_STENCIL format. So, allow it in both the functions.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Remove redundant if checks in _mesa_texstore_xx_xx() functions

This patch contains non-functional changes. Assertion checks made
earlier in the functions make the if checks redundant. So, remove
the if checks and unindent the code in if block.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Add new helper function _mesa_unpack_depth_stencil_row()

This patch makes non-functional changes in the code. New helper
function added here will make it easier to support more data
types in the following patches.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Add support to unpack depth-stencil texture in to FLOAT_32_UNSIGNED_INT_24_8_REV

V2: Follow the new naming convention for unpack functions.
    Use double precision for converting Z24 to a float.
V3: Unpack stencil value to most significant byte.
    Use 'struct z32f_x24s8' type.
V4: Unpack stencil value to least significant byte.
    Add a comment to clarify stencil packing.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
mesa: Allow FLOAT_32_UNSIGNED_INT_24_8_REV in get_tex_depth_stencil()

Fixes a crash in Khronos OpenGL CTS packed_pixels tests.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Use location VERT_ATTRIB_GENERIC0 for vertex attribute 0

In OpenGL 3.1 attribute 0 becomes non-magic, just like in
OpenGL ES 2.0. Earlier versions of OpenGL used attribute 0
exclusively for vertex position.

Fixes 4 Khronos OpenGL CTS failures:
glGetVertexAttrib
depth24_basic
depth24_precision
rgb8_rgba8_rgb

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: Fix querying nth element of an array variable in a shader program

This patch changes the behavior of glGetAttribLocation(),
glGetFragDataLocation() and glGetFragDataIndex() functions.

Code changes handle the cases described in following example:
vertex shader:
layout(location = 1)in vec4[4] a;
layout(location = 6)in vec4 b;
void main()
{
}

fragment shader:
layout (location = 1) out vec4[4] c;
layout (location = 6) out vec4 d;
void main()
{
}

Currently glGetAttribLocation("a") and glGetFragDataLocation("c") returns
1. glGetAttribLocation("a[i]") and glGetFragDataLocation("c[i]"), where
i = {0, 1, 2, 3}, returns -1. But expected locations for array indices
are: 1, 2, 3 and 4 respectively.

glGetAttribLocation(c) and glGetFragDataLocation(d) returns 6. Querying
glGetAttribLocation(c[0]) and glGetFragDataLocation(d[0]) returns -1.
It's a weird query but still valid. Should return 6 here.

Fixes Khronos OpenGL CTS test explicit_attrib_location_room.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>