summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Slightly restructure error generation in validate_explicit_locationIan Romanick2013-10-301-11/+11
| | | | | | | | | | | | | Use mode_string to get the name of the variable mode. Slightly change the control flow. Both of these changes make it easier to support separate shader object location layouts. The format of the message changed because mode_string can return a string like "shader output". This would result in an awkward message like "vertex shader shader output..." Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Make mode_string function globally availableIan Romanick2013-10-303-23/+46
| | | | | | | | | | | | | | | | | | I made this a function (instead of a method of ir_variable) because it made the change set smaller, and I expect that there will be an overload that takes an ir_var_mode enum. Having both functions used the same way seemed better. v2: Add missing case for ir_var_system_value. v3: Change the ir_var_mode_count case to just break. Move the assertion and the return outside the switch-statment. In the unlikely event that var->mode is an invalid value other than ir_var_mode_count, the assertion will still fire, and in release builds we won't wind up returning a garbage pointer. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Eliminate the global check in validate_explicit_locationIan Romanick2013-10-301-3/+2
| | | | | | | | | Since the separation of ir_var_function_in and ir_var_shader_in (similar for out), this check is no longer necessary. Previously, global_scope was the only way to tell which was which. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Extract explicit location code from apply_type_qualifier_to_variableIan Romanick2013-10-301-75/+84
| | | | | | | | | | | | Future patches will add some extra code to this path, and some of that code will want to exit from the explicit location code early. v2: Change a geometry shader "break" to a "return" so that try to apply a bogus geometry shader location qualifier (which could cause cascading errors). Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: fix crash introduced by the previous commitMarek Olšák2013-10-301-1/+1
|
* glsl: break the gl_FragData array into separate gl_FragData[i] variablesMarek Olšák2013-10-291-33/+134
| | | | | | | | | | | | | | | | This avoids a defect in lower_output_reads. The problem is lower_output_reads treats the gl_FragData array as a single variable. It first redirects all output writes to a temporary variable (array) and then writes the whole temporary variable to the output, generating assignments to all elements of gl_FragData. BTW this pass can be modified to lower all arrays, not just inputs and outputs. The question is whether it is worth it. Reviewed-by: Paul Berry <[email protected]> v2: addressed Paul Berry's comments
* glsl: Fix the function inlining pass to deal with general opaque arguments.Francisco Jerez2013-10-291-33/+33
| | | | | | | Almost a trivial change, it boils down to renaming a few identifiers so their names still make sense for opaque types other than sampler. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add built-in functions and constants required for ↵Francisco Jerez2013-10-295-0/+89
| | | | | | | | ARB_shader_atomic_counters. v2: Represent atomics as GLSL intrinsics. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Basic support for built-in intrinsics.Francisco Jerez2013-10-294-11/+64
| | | | | | | | | | | | | | | | | Fix the linker to deal with intrinsic functions which are undefined all the way down to the driver back-end, and introduce intrinsic definition helpers in the built-in generator. We still need to figure out what kind of interface we want for drivers to communicate to the GLSL front-end which of the supported intrinsics should use a default GLSL implementation and which should use a hardware-specific override. As there's no default GLSL implementation for atomic ops, this seems like something we can worry about later on. Reviewed-by: Ian Romanick <[email protected]> v2: Define local helper function to generate ir_call nodes in the builtin generator.
* glsl: Add type predicate to check whether a type contains any opaque types.Francisco Jerez2013-10-293-0/+27
| | | | | | | | | | | And use it to forbid comparisons of opaque operands. According to the GL 4.2 specification: > Except for array indexing, structure member selection, and > parentheses, opaque variables are not allowed to be operands in > expressions. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add new atomic_uint built-in GLSL type.Francisco Jerez2013-10-2910-1/+49
| | | | | | | | | v2: Fix GLSL version in which the type became available. Add contains_atomic() convenience method. Split off atomic counter comparison error checking to a separate patch that will handle all opaque types. Include new ir_variable fields for atomic types. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add extension enables for ARB_shader_atomic_counters.Francisco Jerez2013-10-292-0/+3
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add support for ARB_shader_atomic_counters.Francisco Jerez2013-10-292-0/+8
| | | | | | | | | | | | | | | This patch implements the common support code required for the ARB_shader_atomic_counters extension. It defines the necessary data structures for tracking atomic counter buffer objects (from now on "ABOs") associated with some specific context or shader program, it implements support for binding buffers to an ABO binding point and querying the existing atomic counters and buffers declared by GLSL shaders. v2: Fix extension checks. Drop unused MAX_ATOMIC_BUFFERS constant. Acked-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* ralloc: Hook up C++ destructors to ralloc when necessary.Francisco Jerez2013-10-291-0/+14
| | | | | | | | | | | | | This patch makes sure that class destructors are called as they should be when a C++ object allocated by ralloc is released. Based on a previous patch by Kenneth Graunke, but it doesn't exhibit the ~0.8% performance regression in shader compilation times because we now use the HAS_TRIVIAL_DESTRUCTOR() macro to detect the typical case where the indirect function call can be avoided because the object's destructor doesn't need to do anything. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Generalize MSVC fix for strcasecmp().Paul Berry2013-10-291-7/+1
| | | | | | | | This will let us use strcasecmp() from anywhere inside Mesa without having to worry about the fact that it doesn't exist in MSVC. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Drop no-op shifts involving 0.Eric Anholt2013-10-281-0/+10
| | | | | | | | | | | | I noticed this in a shader in Unigine Heaven that was spilling. While it doesn't really reduce register pressure, it shaves a few instructions anyway (7955 -> 7882). v2: Fix turning "0 >> x" into "x" instead of "0" (caught by Erik Faye-Lund). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use ir_builder more in opt_algebraic.Eric Anholt2013-10-281-30/+10
| | | | | | | | | While ir_builder is slightly less efficient, we're only increasing the work when there's actual optimization being done, and it's way more readable code. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Move common code out of opt_algebraic's handle_expression().Eric Anholt2013-10-281-78/+39
| | | | | | | | | | Matt and I had each screwed up these common required patterns recently, in ways that wouldn't have been noticed for a long time if not for code review. Just enforce it in the caller so that we don't rely on code review catching these bugs. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add check for unsized arrays to glsl typesTimothy Arceri2013-10-287-26/+30
| | | | | | | | | | | | | | | | | | | | The main purpose of this patch is to increase readability of the array code by introducing is_unsized_array() to glsl_types. Some redundent is_array() checks are also removed, and small number of other related clean ups. The introduction of is_unsized_array() should also make the ARB_arrays_of_arrays code simpler and more readable when it arrives. V2: Also replace code that checks for unsized arrays directly with the length variable Signed-off-by: Timothy Arceri <[email protected]> v3 (Paul Berry <[email protected]>): clean up formatting. Separate whitespace cleanups to their own patch. Reviewed-by: Paul Berry <[email protected]>
* glsl: whitespace cleanups.Timothy Arceri2013-10-281-3/+0
| | | | | | | | | Signed-off-by: Timothy Arceri <[email protected]> v2 (Paul Berry <[email protected]>): Separate from "glsl: Add check for unsized arrays to glsl types". Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix commentTimothy Arceri2013-10-281-1/+1
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Move error message inside validation check reducing duplicate message ↵Timothy Arceri2013-10-271-13/+14
| | | | | | | | | handling v2 (Paul Berry <[email protected]): Fix precedence error in call to _mesa_glsl_error(). Reviewed-by: Paul Berry <[email protected]>
* glsl: add signatures for textureGatherOffsets()Chris Forbes2013-10-261-0/+30
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add support for texture functions with offset arraysChris Forbes2013-10-261-0/+9
| | | | | | | This is needed for textureGatherOffsets() Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add new textureGather[Offset]() overloads for shadow samplersChris Forbes2013-10-261-0/+10
| | | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for separate reference Z for shadow samplersChris Forbes2013-10-261-5/+15
| | | | | | | | | | ARB_gpu_shader5's textureGather*() functions which take shadow samplers have a separate `refz` parameter rather than adding it to the coordinate. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: relax const offset requirement for textureGatherOffsetChris Forbes2013-10-261-20/+41
| | | | | | | | | | Prior to ARB_gpu_shader5 / GLSL 4.0, the offset is required to be a constant expression. With that extension, it is relaxed to be an arbitrary expression. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add ARB_gpu_shader5 textureGatherOffset signaturesChris Forbes2013-10-261-0/+16
| | | | | | | | - gsampler2DRect - optional `comp` parameter Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Optimize (not A) and (not B) into not (A or B).Matt Turner2013-10-251-0/+9
| | | | | | No shader-db changes, but seems like a good idea. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Optimize (not A) or (not B) into not (A and B).Matt Turner2013-10-251-0/+12
| | | | | | | | A few Serious Sam 3 shaders affected: instructions in affected programs: 4384 -> 4344 (-0.91%) Reviewed-by: Eric Anholt <[email protected]>
* glsl: When disabling gl_PerVertex variables, check that mode matches.Paul Berry2013-10-241-1/+2
| | | | | | | | | | | | | | | | | | | In commit 1b4a737 (glsl: Support redeclaration of VS and GS gl_PerVertex output), I added code to ensure that when an unnamed gl_PerVertex interface block is redeclared, any ir_variables that weren't included in the redeclaration are removed from the IR (and the symbol table). This ensures that only those variables that were explicitly redeclared may be used. However, when I wrote this code, I neglected to match the variable mode when finding variables to remove. This meant that redeclaring a built-in output block might cause the built-in input gl_in to be accidentally removed. Fixes piglit test gs-redeclares-pervertex-out-only. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Remove unused gl_PerVertex interface blocks.Paul Berry2013-10-241-0/+90
| | | | | | | | | | | | | | | | The GLSL 4.10 rules for redeclaration of built-in interface blocks (which we've chosen to regard as clarifications of GLSL 1.50) only require gl_PerVertex blocks to match in shaders that actually use those blocks. The easiest way to implement this is to detect situations where a compiled shader doesn't refer to any elements of gl_PerVertex, and remove all the associated ir_variables from the shader at the end of ast-to-ir conversion. Fixes piglit tests linker/interstage-{pervertex,pervertex-in,pervertex-out}-redeclaration-unneeded. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Call check_builtin_array_max_size when redeclaring gl_in.Paul Berry2013-10-241-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | Normally when a built-in array (such as gl_ClipDistance) is redeclared, we call get_variable_being_redeclared() to do the redeclaration, and it in turn calls check_builtin_array_max_size() to make sure that the redeclared array size isn't too large. However when a built-in array is redeclared as part of redeclaring gl_in, we don't call get_variable_being_redeclared() (since the individual built-ins aren't each represented by their own ir_variable anymore). So we need to add an explicit call to check_builtin_array_max_size() to make sure the new array size isn't too large. Note: at the moment this is redundant with a test that's done at link time, so there's no change to piglit results. But the patch that follows will prevent link errors from being reported if gl_PerVertex isn't used, so in order to prevent that patch from causing regressions, we need to add the compile check now. Besides, it's nicer to report this error at compile time anyhow. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Account for interface block lowering in program_resource_visitor.Paul Berry2013-10-241-1/+57
| | | | | | | | | | | | | | When program_resource_visitor visits variables that were created by lower_named_interface_blocks, it needs to do extra work to un-do the effects of lower_named_interface_blocks and construct the proper API names. Fixes piglit test spec/glsl-1.50/execution/interface-blocks-api-access-members. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: mark variables produced by lower_named_interface_blocks.Paul Berry2013-10-242-0/+20
| | | | | | | | | | | These variables will need to be treated specially by program_resource_visitor, so that they can be addressed through the API using their interface block name (and array index, for interface block arrays). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Keep track of centroid/interpolation mode for interface block members.Paul Berry2013-10-245-0/+38
| | | | | | | | | | Fixes piglit tests: - interface-block-interpolation-{array,named,unnamed} - glsl-1.50-interface-block-centroid {array,named,unnamed} Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Pass variable mode into ast_process_structure_or_interface_block().Paul Berry2013-10-241-16/+23
| | | | | | | | | Later patches will use this information to do proper error checking of interpolation qualifiers that appear inside of interface blocks. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract interpretation of interpolation to its own function.Paul Berry2013-10-241-28/+42
| | | | | | | | | In future patches, we will need this in order to interpret interpolation qualifiers that appear inside interface blocks. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Pull interpolation_string() out of ir_variable.Paul Berry2013-10-244-20/+22
| | | | | | | | | Future patches will need to call this function when there isn't an ir_varible present to refer to. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: set explicit_location correctly in lower_named_interface_blocks.Paul Berry2013-10-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When lower_named_interface_blocks lowers a built-in interface block member to an ir_variable, it needs to set explicit_location in the ir_variable. Otherwise the linker gets confused and treats the variable as a generic varying. Fixes the following piglit tests, which were regressed by commit 63974c0 (glsl: Simplify the interface to link_invalidate_variable_locations): - clip-distance-bulk-copy - clip-distance-in-bulk-read - clip-distance-in-explicitly-sized - clip-distance-in-param - clip-distance-in-values - core-inputs - gs-redeclares-both-pervertex-blocks - gs-redeclares-pervertex-in-only - redeclare-pervertex-subset-vs-to-gs - unsized-in-named-interface-block-gs - unsized-in-named-interface-block-multiple - unsized-in-unnamed-interface-block-gs - unsized-in-unnamed-interface-block-multiple Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70820 Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/gs: Fix transform feedback of gl_ClipDistance.Paul Berry2013-10-242-1/+3
| | | | | | | | | | | | | | | | | | | | | | Since gl_ClipDistance is lowered from an array of floats to an array of vec4's during compilation, transform feedback has special logic to keep track of the pre-lowered array size so that attempting to perform transform feedback on gl_ClipDistance produces a result with the correct size. Previously, this special logic always consulted the vertex shader's size for gl_ClipDistance. This patch fixes it so that it uses the geometry shader's size for gl_ClipDistance when a geometry shader is in use. Fixes piglit test spec/glsl-1.50/transform-feedback-type-and-size. v2: Change the type of LastClipDistanceArraySize to "unsigned", and clarify the comment above it. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: silence unused 'var' variable warningBrian Paul2013-10-241-2/+2
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/gs: Prevent illegal input/output primitive types.Paul Berry2013-10-231-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the GLSL 1.50 spec, section 4.3.8.1 (Input Layout Qualifiers): The layout qualifier identifiers for geometry shader inputs are layout-qualifier-id points lines lines_adjacency triangles triangles_adjacency And from section 4.3.8.2 (Output Layout Qualifiers) The layout qualifier identifiers for geometry shader outputs are layout-qualifier-id points line_strip triangle_strip max_vertices = integer-constant We were erroneously allowing line_strip and triangle_strip to be used as input qualifiers, and we were allowing lines, lines_adjacency, triangles, and triangles_adjacency to be used as output qualifiers. Fixes piglit tests "glsl-1.50-gs-{input,output}-layout-qualifiers *". Reviewed-by: Ian Romanick <[email protected]>
* glsl: Simplify the interface to link_invalidate_variable_locationsIan Romanick2013-10-223-44/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | The unit tests added in the previous commits prove some things about the state of some internal data structures. The most important of these is that all built-in input and output variables have explicit_location set. This means that link_invalidate_variable_locations doesn't need to know the range of non-generic shader inputs or outputs. It can simply reset location state depending on whether explicit_location is set. There are two additional assumptions that were already implicit in the code that comments now document. - ir_variable::is_unmatched_generic_inout is only used by the linker when connecting outputs from one shader stage to inputs of another shader stage. - Any varying that has explicit_location set must be a built-in. This will be true until GL_ARB_separate_shader_objects is supported. As a result, the input_base and output_base parameters to link_invalidate_variable_locations are no longer necessary, and the code for resetting locations and setting is_unmatched_generic_inout can be simplified. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl/tests: Unit test vertex shader in / out with ↵Ian Romanick2013-10-222-0/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | link_invalidate_variable_locations Validates: - ir_variable::explicit_location should not be modified. - If ir_variable::explicit_location is not set, ir_variable::location, ir_variable::location_frac, and ir_variable::is_unmatched_generic_inout must be reset to 0. - If ir_variable::explicit_location is set, ir_variable::location should not be modified. ir_variable::location_frac, and ir_variable::is_unmatched_generic_inout must be reset to 0. Previous unit tests have shown that all non-generic inputs / outputs have explicit_location set. v2: Split the link_invalidate_variable_locations interface change out to a separate patch. Remove the vertex_in_builtin_without_explicit and vertex_out_builtin_without_explicit tests. There was a lot of good discussion about this on the mailing list to which I refer the interested reader. Both changes suggested by Paul. http://lists.freedesktop.org/archives/mesa-dev/2013-October/046652.html Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Modify interface to link_invalidate_variable_locationsIan Romanick2013-10-222-7/+7
| | | | | | | | | | | This will make it easier to unit test this function in successive patches. Also, correct the prototype in linker.h. It was... wrong. v2: Split the interface change from adding the unit tests. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl/tests: Verify geometry shader built-ins generated by ↵Ian Romanick2013-10-221-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | _mesa_glsl_initialize_variables Checks that the variables generated meet certain criteria. - Geometry shader inputs have an explicit location. - Geometry shader outputs have an explicit location. - Fragment shader-only varying locations are not used. - Geometry shader uniforms and system values don't have an explicit location. - Geometry shader constants don't have an explicit location and are read-only. - No other kinds of geometry variables exist. It does not verify that an specific variables exist. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl/tests: Verify fragment shader built-ins generated by ↵Ian Romanick2013-10-221-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | _mesa_glsl_initialize_variables Checks that the variables generated meet certain criteria. - Fragment shader inputs have an explicit location. - Fragment shader outputs have an explicit location. - Vertex / geometry shader-only varying locations are not used. - Fragment shader uniforms and system values don't have an explicit location. - Fragment shader constants don't have an explicit location and are read-only. - No other kinds of fragment variables exist. It does not verify that an specific variables exist. v2: Use _mesa_varying_slot_in_fs in fragment_builtin.inputs_have_explicit_location. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl/tests: Verify vertex shader built-ins generated by ↵Ian Romanick2013-10-222-0/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | _mesa_glsl_initialize_variables Checks that the variables generated meet certain criteria. - Vertex shader inputs have an explicit location. - Vertex shader outputs have an explicit location. - Fragment shader-only varying locations are not used. - Vertex shader uniforms and system values don't have an explicit location. - Vertex shader constants don't have an explicit location and are read-only. - No other kinds of vertex variables exist. It does not verify that an specific variables exist. v2: Fix memory management mistakes in common_builtin::string_starts_with_prefix. Clean up error message reporting in common_builtin::no_invalid_variable_modes. Both suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: When constructing a variable with an interface type, set interface_typeIan Romanick2013-10-226-4/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ever since the addition of interface blocks with instance names, we have had an implicit invariant: var->type->is_interface() == (var->type == var->interface_type) The odd use of == here is intentional because !var->type->is_interface() implies var->type != var->interface_type. Further, if var->type->is_array() is true, we have a related implicit invariant: var->type->fields.array->is_interface() == (var->type->fields.array == var->interface_type) However, the ir_variable constructor doesn't maintain either invariant. That seems kind of silly... and I tripped over it while writing some other code. This patch makes the constructor do the right thing, and it introduces some tests to verify that behavior. v2: Add general-ir-test to .gitignore. Update the description of the ir_variable invariant for arrays in the commit message. Both suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>