summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* 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]>
* glsl: Optimize -(-expr) into expr.Matt Turner2013-10-211-0/+10
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Optimize abs(-expr) and abs(abs(expr)) into abs(expr).Matt Turner2013-10-211-0/+18
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Use saved values instead of recomputing them.Matt Turner2013-10-211-8/+4
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/linker: Allow mixing of desktop GLSL versions.Paul Berry2013-10-211-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, Mesa followed the linkage rules outlined in the GLSL 1.20-1.40 specs, which (collectively) said that GLSL versions 1.10 and 1.20 could be linked together, but no other versions could be linked. In GLSL 4.30, the linkage rules were relaxed so that any two desktop GLSL versions can be linked together. This change was made because it reflected the behaviour of nearly all existing implementations (see Khronos bug 8463). Mesa was one of the few (perhaps the only) exceptions to prohibit cross-linking of some GLSL versions. Since the GLSL linkage rules were deliberately relaxed in order to match the behaviour of existing implementations, it seems appropriate to relax the rules in Mesa too (even though Mesa doesn't support GLSL 4.30 yet). Note that linking ES and desktop shaders is still prohibited, as is linking ES shaders having different GLSL versions. Fixes piglit tests "shaders/version-mixing {interstage,intrastage}". Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Initialize per_vertex_accumulator::fields.Vinson Lee2013-10-181-1/+2
| | | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix MSVC build (missing strcasecmp())Paul Berry2013-10-171-1/+7
| | | | | | MSVC doesn't have a strcasecmp() function; it uses _stricmp() instead. Reviewed-by: Jose Fonseca <[email protected]>
* glsl: In update_max_array_access, fix interface instance check.Paul Berry2013-10-171-3/+3
| | | | | | | | | | | | | | | | | | | | In commit f878d20 (glsl: Update ir_variable::max_ifc_array_access properly), I accidentally used the wrong kind of check to determine whether the variable being accessed was an interface instance (I used var->get_interface_type() != NULL when I should have used var->is_interface_instance()). As a result, if an unnamed interface block contained a struct which contained an array, update_max_array_access() would mistakenly interpret the struct as a named interface block and try to dereference a null var->max_ifc_array_access. This patch corrects the check, fixing the null dereference. Fixes piglit test interface-block-struct-nesting. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70368 Reviewed-by: Matt Turner <[email protected]>
* glsl: Treat layout-qualifier-id's as case-insensitive in desktop GLSL.Paul Berry2013-10-171-15/+59
| | | | | | | | | | | | | | | | In desktop GLSL, location qualifiers are case-insensitive. In GLSL ES, they are case-sensitive. This patch handles the difference by using a new function to match layout qualifiers, match_layout_qualifier(), which calls either strcmp() or strcasecmp() as appropriate. Fixes piglit tests: - layout-not-case-sensitive-in.geom - layout-not-case-sensitive-max-vert.geom - layout-not-case-sensitive-out.geom - layout-not-case-sensitive.frag Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Optimize mul(a, -1) into neg(a).Matt Turner2013-10-161-0/+23
| | | | | | | | | | | Two extra instructions in some heroesofnewerth shaders, but a win for everything else. total instructions in shared programs: 1531352 -> 1530815 (-0.04%) instructions in affected programs: 121898 -> 121361 (-0.44%) Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add new GLSL 1.50 constants.Paul Berry2013-10-153-0/+51
| | | | | | | | | | | | | | | | | | | | | This patch populates the following built-in GLSL 1.50 variables based on constants stored in ctx->Const: - gl_MaxVertexOutputComponents - gl_MaxGeometryInputComponents - gl_MaxGeometryOutputComponents - gl_MaxFragmentInputComponents - gl_MaxGeometryTextureImageUnits - gl_MaxGeometryOutputVertices - gl_MaxGeometryTotalOutputComponents - gl_MaxGeometryUniformComponents - gl_MaxGeometryVaryingComponents On i965/gen7, fixes all Piglit tests in "spec/glsl-1.50/built-in constants/*" except for gl_MaxCombinedTextureImageUnits and gl_MaxGeometryUniformComponents. Reviewed-by: Matt Turner <[email protected]>
* glsl: fix signed/unsigned comparison warningBrian Paul2013-10-111-1/+1
|
* glsl: Remove extraneous .dir-locals.elIan Romanick2013-10-111-3/+0
| | | | | | | | This was overriding the top-level .dir-locals.el causing some settings (like forcing spaces instead of tabs!) to be lost. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Don't allow gl_PerVertex to be redeclared after it's been used.Paul Berry2013-10-101-0/+53
| | | | | | | | | | | Fixes piglit tests: - spec/glsl-1.50/compiler/gs-redeclares-pervertex-in-after-other-usage.geom - spec/glsl-1.50/compiler/gs-redeclares-pervertex-out-after-other-usage.geom - spec/glsl-1.50/compiler/gs-redeclares-pervertex-out-after-usage.geom - spec/glsl-1.50/compiler/vs-redeclares-pervertex-out-after-other-usage.vert - spec/glsl-1.50/compiler/vs-redeclares-pervertex-out-after-usage.vert Reviewed-by: Ian Romanick <[email protected]>
* glsl: Support redeclaration of GS gl_PerVertex input.Paul Berry2013-10-101-2/+21
| | | | | | | Fixes piglit test spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Catch redeclaration of interface block instance names at compile time.Paul Berry2013-10-101-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From section 4.1.9 (Arrays) of the GLSL 4.40 spec (as of revision 7): However, unless noted otherwise, blocks cannot be redeclared; an unsized array in a user-declared block cannot be sized through redeclaration. The only place where the spec notes that interface blocks can be redeclared is to allow for redeclaration of built-in interface blocks such as gl_PerVertex. Therefore, user-defined interface blocks can never be redeclared. This is a clarification of previous intent (see Khronos bug 10659). We were already preventing interface block redeclaration using the same block name at compile time, but we weren't preventing interface block redeclaration using the same instance name (and different block names) at compile time. And we weren't preventing an instance name from conflicting with a previously-declared ordinary variable. In practice the problem would be caught at link time, but only because of a coincidence: since ast_interface_block::hir() wasn't doing any checking to see if the instance name already existed in the shader, it was creating a second ir_variable in the shader having the same name but a different type. Coincidentally, when the linker checked for intrastage consistency of global variable declarations, it treated the two declarations from the same shader as a conflict, so it reported a link error. But it seems dangerous to rely on that linker behaviour to catch illegal redeclarations that really ought to be detected at compile time. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Support redeclaration of VS and GS gl_PerVertex output.Paul Berry2013-10-101-2/+60
| | | | | | | | Fixes piglit tests: - spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs - spec/glsl-1.50/execution/redeclare-pervertex-subset-vs Reviewed-by: Ian Romanick <[email protected]>
* glsl: Error check redeclarations of gl_PerVertex.Paul Berry2013-10-101-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | This patch verifies that: - The gl_PerVertex input interface block may only be redeclared in a geometry shader, and that it may only be redeclared as gl_in[]. - The gl_PerVertex output interface block may only be redeclared in a vertex or geometry shader, and that it may only be redeclared as a non-array without an interface name. - gl_PerVertex may not be redeclared as any other type of interface block (i.e. as a uniform interface block). As a side-effect, the code now keeps track of what the previous declaration of gl_PerVertex was--this will be needed in future patches. Fixes piglit tests: - spec/glsl-1.50/compiler/gs-redeclares-pervertex-in-with-incorrect-name.geom - spec/glsl-1.50/compiler/gs-redeclares-pervertex-out-as-array.geom - spec/glsl-1.50/compiler/gs-redeclares-pervertex-out-with-instance-name.geom Reviewed-by: Ian Romanick <[email protected]>
* glsl: Make it possible to disable a variable in the symbol table.Paul Berry2013-10-102-0/+23
| | | | | | | | | | | | | In later patches, we'll use this in order to implement the required behaviour that after the gl_PerVertex interface block has been redeclared, only members of the redeclared interface block may be used. v2: Update the function name and comment to clarify that we aren't actually removing the variable from the symbol table, just disabling it. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add an ir_variable::reinit_interface_type() function.Paul Berry2013-10-101-0/+25
| | | | | | | | This will be used by future patches to change an ir_variable's interface type when the gl_PerVertex built-in interface block is redeclared. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Generalize processing of variable redeclarations.Paul Berry2013-10-101-8/+7
| | | | | | | | | | | | | This patch modifies the get_variable_being_redeclared() function so that it no longer relies on the ast_declaration for the variable being redeclared. In future patches, this will allow get_variable_being_redeclared() to be used for processing redeclarations of the built-in gl_PerVertex interface block. v2: Also make get_variable_being_redeclared() static. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't allow invalid identifiers as struct names.Paul Berry2013-10-101-0/+2
| | | | | | | | Fixes piglit test spec/glsl-1.10/compiler/struct/struct-name-uses-gl-prefix.vert. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't allow invalid identifiers as interface block instance names.Paul Berry2013-10-101-0/+3
| | | | | | | | | | | | | Note: we need to make an exception for the gl_PerVertex interface block, since in geometry shaders it is allowed to be redeclared with the instance name gl_in. Future patches will make redeclaration of gl_PerVertex work properly. Fixes piglit test spec/glsl-1.50/compiler/interface-block-instance-name-uses-gl-prefix.vert. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't allow invalid identifier names in struct/interface fields.Paul Berry2013-10-101-3/+9
| | | | | | | | | | | | | | | Note: we need to make an exception for the gl_PerVertex interface block, since built-in variables are allowed to be redeclared inside it. Future patches will make redeclaration of gl_PerVertex work properly. Fixes piglit tests: - spec/glsl-1.50/compiler/interface-block-array-elem-uses-gl-prefix.vert - spec/glsl-1.50/compiler/named-interface-block-elem-uses-gl-prefix.vert - spec/glsl-1.50/compiler/unnamed-interface-block-elem-uses-gl-prefix.vert Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't allow invalid identifiers as interface block names.Paul Berry2013-10-101-0/+4
| | | | | | | | | | | | Note: we need to make an exception for the gl_PerVertex interface block, since this is allowed to be redeclared. Future patches will make redeclaration of gl_PerVertex work properly. Fixes piglit test spec/glsl-1.50/compiler/interface-block-name-uses-gl-prefix.vert. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't allow unnamed interface blocks to redeclare variables.Paul Berry2013-10-101-0/+3
| | | | | | | | | | | | Note: some limited amount of redeclaration is actually allowed, provided the shader is redeclaring the built-in gl_PerVertex interface block. Support for this will be added in future patches. Fixes piglit tests spec/glsl-1.50/compiler/unnamed-interface-block-elem-conflicts-with-prev-{block-elem,global}.vert. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Refactor code to check that identifier names are valid.Paul Berry2013-10-101-33/+32
| | | | | | | | | | | | | | GLSL reserves identifiers beginning with "gl_" or containing "__", but we haven't been consistent about enforcing this rule. This patch makes a new function to check whether identifier names are valid. In the process it closes a loophole where we would previously allow function argument names to contain "__". v2: Rename check_valid_identifier() -> validate_identifier(). Add curly braces in validate_identifier(). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Account for location field when comparing interface blocks.Paul Berry2013-10-101-0/+3
| | | | | | | | | | | | | | | | | | | In commit e2660770731b018411fbe1620cacddaf8dff5287 (glsl: Keep track of location for interface block fields), I neglected to update glsl_type::record_key_compare to account for the fact that interface types now contain location information. As a result, interface types that differ only by their location information would not be properly distinguished. At the moment this is not a problem, because the only interface block in which location information != -1 is gl_PerVertex, and gl_PerVertex is always created in the same way. However, in the patches that follow, we'll be adding new ways to create gl_PerVertex (by redeclaring it), so we'll need location information to be handled properly. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Construct gl_PerVertex interfaces for GS and VS outputs.Paul Berry2013-10-101-7/+19
| | | | | | | | | Although these interfaces can't be accessed directly by GLSL (since they don't have an instance name), they will be necessary in order to allow redeclarations of gl_PerVertex. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Refactor code for creating gl_PerVertex interface block.Paul Berry2013-10-101-23/+49
| | | | | | | | | | Currently, we create just a single gl_PerVertex interface block for geometry shader inputs. In later patches, we'll also need to create an interface block for geometry and vertex shader outputs. Moving the code into its own class will make reuse easier. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix block name of built-in gl_PerVertex interface block.Paul Berry2013-10-101-1/+1
| | | | | | | | | Previously, we erroneously used the name "gl_in" for both the block name and the instance name. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Construct gl_in with a location of -1.Paul Berry2013-10-101-1/+1
| | | | | | | | | | | | We use a location of -1 for variables which don't have their own assigned locations--this includes ir_variables which represent named interface blocks. Technically the location assigned to gl_in doesn't matter, since gl_in is only accessed via its members (which have their own locations). But it's nice to be consistent. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Modify array_sizing_visitor to handle unnamed interface blocks.Paul Berry2013-10-092-2/+88
| | | | | | | | | | | | | | | | | | | We were already setting the array size of unsized arrays that appeared inside unnamed interface blocks, but we weren't updating ir_variable::interface_type to reflect the new array size, causing bogus link errors. This patch causes array_sizing_visitor to keep track of all the unnamed interface types it sees, and the ir_variables corresponding to each one. After the visitor runs, a new function, fixup_unnamed_interface_types(), adjusts each unnamed interface type to correctly correspond with the array sizes in the ir_variables. Fixes piglit tests: - spec/glsl-1.50/execution/unsized-in-unnamed-interface-block-gs - spec/glsl-1.50/execution/unsized-in-unnamed-interface-block-multiple Reviewed-by: Jordan Justen <[email protected]>
* glsl: Update call_link_visitor to update max_ifc_array_access.Paul Berry2013-10-091-12/+25
| | | | | | | | | | | | | | | | | | When multiple shaders of the same type access an interface block containing an unsized array, we need to set the array size based on the maximum array element accessed across all the shaders. This is similar to what we already do with unsized arrays occurring outside of interface blocks. Note: one corner case is not yet addressed by these patches: the case where one compilation unit defines an interface block containing unsized arrays and another compilation unit defines the same interface block containing sized arrays. Fixes piglit test: - spec/glsl-1.50/execution/unsized-in-named-interface-block-multiple Reviewed-by: Jordan Justen <[email protected]>
* glsl/linker: Modify array_sizing_visitor to handle named interface blocks.Paul Berry2013-10-092-6/+87
| | | | | | | | | | | | | | | | | Unsized arrays appearing inside named interface blocks now get a proper size assigned by the array_sizing_visitor. Fixes piglit tests: - spec/glsl-1.50/execution/unsized-in-named-interface-block - spec/glsl-1.50/execution/unsized-in-named-interface-block-gs - spec/glsl-1.50/linker/unsized-in-named-interface-block - spec/glsl-1.50/linker/unsized-in-named-interface-block-gs - spec/glsl-1.50/linker/unsized-in-unnamed-interface-block-gs (*) (*) is fixed by dumb luck--support for unsized arrays in unnamed interface blocks will come in a later patch. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Update ir_variable::max_ifc_array_access properly.Paul Berry2013-10-091-0/+37
| | | | | | | | | | | | This patch modifies update_max_array_access() so that it updates ir_variable::max_ifc_array_access to reflect the shader's use of arrays appearing within interface blocks. v2: Use an ordinary function in ast_array_index.cpp rather than a virtual function in ir_rvalue. Avoid dereferencing NULL when handling accesses to ordinary structs. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Sanity check max_ifc_array_access in ir_validate::visit(ir_variable *).Paul Berry2013-10-091-0/+20
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add an ir_variable::max_ifc_array_access field.Paul Berry2013-10-093-1/+25
| | | | | | | | | For interface blocks that contain arrays, this field will contain the maximum element of each contained array that is accessed by the shader. This is a first step toward supporting unsized arrays in interface blocks. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Make accessor functions for ir_variable::interface_type.Paul Berry2013-10-099-33/+51
| | | | | | | In a future patch, this will allow us to enforce invariants when the interface type is updated. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Move update of max_array_access into a separate function.Paul Berry2013-10-091-17/+30
| | | | | | | | | | | | | | | | | Currently, when converting an access to an array element from ast to IR, we need to see if the array is an ir_dereference_variable, and if so update the variable's max_array_access. When we add support for unsized arrays in interface blocks, we'll also need to account for cases where the array is an ir_dereference_record and the record is an interface block. To make this easier, move the update into its own function. v2: Use an ordinary function in ast_array_index.cpp rather than a virtual function in ir_rvalue. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add parser support for unsized arrays in interface blocks.Paul Berry2013-10-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although it's not explicitly stated in the GLSL 1.50 spec, unsized arrays are allowed in interface blocks. section 1.2.3 (Changes from revision 5 of version 1.5) of the GLSL 1.50 spec says: * Completed full update to grammar section. Tested spec examples against it: ... * add unsized arrays for block members And section 7.1 (Vertex and Geometry Shader Special Variables) includes an unsized array in the built-in gl_PerVertex interface block: out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; }; Furthermore, GLSL 4.30 contains an example of an unsized array occurring inside an interface block. From section 4.3.9 (Interface Blocks): uniform Transform { // API uses "Transform[2]" to refer to instance 2 mat4 ModelViewMatrix; mat4 ModelViewProjectionMatrix; vec4 a[]; // array will get implicitly sized float Deformation; } transforms[4]; This patch adds the parser rule to support unsized arrays inside interface blocks. Later patches in the series will add the appropriate semantics to handle them. Fixes piglit tests: - spec/glsl-1.50/execution/unsized-in-unnamed-interface-block - spec/glsl-1.50/linker/unsized-in-unnamed-interface-block Reviewed-by: Jordan Justen <[email protected]>
* glsl: Rename the fourth argument to get_interface_instance.Paul Berry2013-10-092-5/+5
| | | | | | | | | Interface declarations have two names associated with them: the block name and the instance name. It's the block name that needs to be passed to get_interface_instance(). This patch renames the argument so that there's no confusion. Reviewed-by: Kenneth Graunke <[email protected]>