mesa/es3: Enable ES 3.0 API and shading language version

v2: Add ARB_internalformat_query to the list of required extensions.

v3: Add OES_depth_texture_cube_map to the list of required extensions.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
i965/Gen6+: Enable ARB_ES3_compatibility extension

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965: Bump maximum supported ES2 context version to 3.0

Since patch "i965: Validate requested GLES context version in
brwCreateContext", we have been able to create ES 3.0 contexts due to the
max version check.  So...bump the max version.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
i965: Use GL_RED for DEPTH_TEXTURE_MODE in ES 3.0 for unsized formats.

Khronos has apparently decided that depth textures with sized formats
(allowed with ARB_internalformat_query or ES 3.0) should be treated as
GL_RED, while unsized formats (an existing feature) should be treated
as GL_INTENSITY for compatibility with ES 2.0.

Ian is proposing changes to ARB_internalformat_query which will make
this actually legal and consistent.

A similar problem exists with GL 4.2, but we're going to ignore that
for the time being.

Tested on Ivybridge: no Piglit regressions; fixes 4 es3conform tests:
- depth_texture_fbo
- depth_texture_fbo_clear
- depth_texture_teximage
- depth_texture_texsubimage

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965: Correct gen6+ guardband calculation.

Too much attention was paid to the first paragraphs, and not enough to
the last little note that "oh, by the way, the rendered things
themselves still have to be clipped to just 8192 wide/high".

Fixes GTF's clip.c test with 4096 or higher width on ivb, where one of
the triangles got the upper half of its pixels dropped.
glsl: Replace most default cases in switches on GLSL type

This makes it easier to find switch-statements that need to be updated
after a new GLSL_TYPE_* is added because the compiler will generate a
warning.

Switch-statements that only had a small number of cases (e.g.,
everything in ir_constant_expression.cpp) were not modified.  I may
regret that decision when we eventually add support for doubles.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
mesa: Track the packing mode of a UBO in gl_uniform_buffer

This allows the next patch to verify that two uniform blocks match
without first calculating the locations of the fields.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
linker: Refactor intra-stage block compatabililty testing

Also slightly change the compatibility test.  Instead of comparing the
offsets of the block variables, compare the packing mode of the blocks.
Ideally we don't want to assign the offsets until a later stage of
linking.

This is put in a new file called link_uniform_blocks.cpp.  Some new
functions related to uniform blocks are going to live in that file as
well.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
glsl: Refactor uniform block parser rules.

The existing code has a lot of duplication; the only difference between
the two cases is whether we merge in an additional layout qualifier.

Apparently creating a layout_qualifieropt rule that can be empty causes
a lot of conflicts and confusion.  However, refactoring out the guts of
the ast_uniform_block creation works fine.

Reviewed-by: Carl Worth <cworth@cworth.org>
glsl: Parse non-array uniform block instance names in GLSL ES 3.00.

In GLSL ES 3.00 (and GLSL 1.50), uniform blocks can have an associated
"instance name", which essentially namespaces the variables inside.

This patch adds basic parsing for this new feature, but doesn't yet hook
it up to actually do anything yet.

It does not support for arrays of interface blocks; a later commit will
take care of that.

This change temporarily regresses the piglit test
interface-name-access-without-interface-name.vert.  This shader failed
to compile before (the expected result), but it failed to compile for
the wrong reason.  This is not a real regression.

v2: Add some comments to ast_uniform_block::instance_name.  Suggested by
Paul Berry.

Reviewed-by: Carl Worth <cworth@cworth.org>
glsl: Parse interface array size

The size is parsed and stored in the AST, but it is not used yet.
Processing of the array size is added in the patch "glsl: Handle
instance array declarations"

v2: Update the commit message (suggested by Carl Worth).  Add a comment
to ast_uniform_block::array_size (suggested by Paul Berry).

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
glsl: Refactor out processing of structure fields

This will soon also be used for processing interface block fields.

v2: Add a comment explaining the interface of
ast_process_structure_or_interface_block.  Suggested by Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl: Add row_major field to glsl_struct_field

For now, this will always be false.  In the near future, an "interface"
type will be added that shares a lot of infrastructure with structures.

v2: Move row_major checking in glsl_type::record_key_compare from the
next patch to this patch.  Suggested by Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl: Add GLSL_TYPE_INTERFACE

Interfaces are structurally identical to structures from the compiler's
point of view.  They have some additional restrictions, and generally
GPUs use different instructions to access them.  Using a different base
type should make this a bit easier.

This commit also adds the glsl_type::interface_packing fields.  For
GLSL_TYPE_INTERFACE types, this will track the specified packing mode.
It is analogous to gl_uniform_buffer::_Packing.

v2: Add serveral missing GLSL_TYPE_INTERFACE cases in switch-statements.

v3: Add information about glsl_type::interface_packing.  Move row_major
checking in glsl_type::record_key_compare from this patch to the
previous patch.  Both suggested by Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl: Generate an interface type for uniform blocks

If the block has an instance name, add the instance name to the symbol
table instead of the individual fields.

Fixes the piglit test interface-name-access-without-interface-name.vert
for real.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
glsl: Add ir_variable::is_in_uniform_block predicate

The way a variable is tested for this property is about to change, and
this makes the code easier to modify.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
glsl: Add ir_variable::interface_type field

For variables that are in an interface block or are an instance of an
interface block, this is the GLSL_TYPE_INTERFACE type for that block.

Convert the ir_variable::is_in_uniform_block method added in the
previous commit to use this field instead of ir_variable::uniform_block.

v2: Fix the place-holder comment on ir_variable::interface_type.
Suggested by Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
glsl: Require that indices into uniform block arrays be constants

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
glsl: Add a predicate to determine whether a variable is an interface block

For the first declaration below, there will be an ir_variable named
"instance" whose type and whose instance_type will be the same
glsl_type.  For the second declaration, there will be an ir_variable
named "f" whose type is float and whose instance_type is B2.

"instance" is an interface instance variable, but "f" is not.

uniform B1 {
    float f;
} instance;

uniform B2 {
    float f;
};

v2: Copy the comment message documentation into the code.  Suggested by
Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
glsl: Modify uniform_field_visitor::recursion to take a row_major parameter

Not used yet, but the UBO layout visitor will use this.

v2: Add some commentary as to why row_major is always set to false in
process.  Suggesed by Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>