summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Use typed foreach_in_list_safe instead of foreach_list_safe.Matt Turner2014-07-011-3/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use typed foreach_in_list instead of foreach_list.Matt Turner2014-07-011-27/+23
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Validate vertex emission in geometry shaders.Iago Toral Quiroga2014-06-301-14/+134
| | | | | | | Check if non-zero streams are used. Fail to link if emitting to unsupported streams or emitting to non-zero streams with output type other than GL_POINTS. Reviewed-by: Chris Forbes <[email protected]>
* glsl: check _mesa_hash_table_create return value in link_uniform_blocksJuha-Pekka Heikkila2014-06-261-0/+2
| | | | | Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: initialize explicit uniform locationsTapani Pälli2014-06-161-0/+114
| | | | | | | | | | | Patch initializes the UniformRemapTable for explicit locations. This needs to happen before optimizations to make sure all inactive uniforms get their explicit locations correctly. v2: fix initialization bug, introduce define for inactive uniforms (Ian) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Eliminate gl_shader_program::InternalSeparateShaderIan Romanick2014-05-021-2/+1
| | | | | | | | | This was a work-around to allow linking a program with only a fragment shader in a GLES context. Now that we have GL_EXT_separate_shader_objects in GLES contexts, we can just use that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Enable GL_EXT_separate_shader_objects for OpenGL ESIan Romanick2014-05-021-1/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Allow geometry shader without vertex shader for separable programsIan Romanick2014-05-021-1/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Assign varying locations for separable programsIan Romanick2014-05-021-3/+13
| | | | Signed-off-by: Ian Romanick <[email protected]>
* glsl: Apply the link error conditions to GL_ARB_fragment_coord_conventionsAnuj Phogat2014-05-011-1/+6
| | | | | | | | | | | | | | | Link error conditions added in previous patch are equally applicable to GL_ARB_fragment_coord_conventions implementation. Extension's spec says: "If gl_FragCoord is redeclared in any fragment shader in a program, it must be redeclared in all the fragment shaders in that program that have a static use of gl_FragCoord. All redeclarations of gl_FragCoord in all fragment shaders in a single program must have the same set of qualifiers." Signed-off-by: Anuj Phogat <[email protected]> Cc: <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Link error if fs defines conflicting qualifiers for gl_FragCoordAnuj Phogat2014-05-011-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL 1.50 spec says: "If gl_FragCoord is redeclared in any fragment shader in a program, it must be redeclared in all the fragment shaders in that program that have a static use gl_FragCoord. All redeclarations of gl_FragCoord in all fragment shaders in a single program must have the same set of qualifiers." This patch causes the shader link to fail if we have multiple fragment shaders with conflicting layout qualifiers for gl_FragCoord. V2: Restructure the code and add conditions to correctly handle the following case: fragment shader 1: layout(origin_upper_left) in vec4 gl_FragCoord; void main() { foo(); gl_FragColor = gl_FragData; } fragment shader 2: layout(pixel_center_integer) in vec4 gl_FragCoord; void foo() { } V3: Allow linking in the following case: fragment shader 1: void main() { foo(); gl_FragColor = gl_FragCoord; } fragment shader 2: in vec4 gl_FragCoord; void foo() { ... } Signed-off-by: Anuj Phogat <[email protected]> Cc: <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Allow overlapping locations for vertex input attributesAnuj Phogat2014-05-011-15/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently overlapping locations of input variables are not allowed for all the shader types in OpenGL and OpenGL ES. From OpenGL ES 3.0 spec, page 56: "Binding more than one attribute name to the same location is referred to as aliasing, and is not permitted in OpenGL ES Shading Language 3.00 vertex shaders. LinkProgram will fail when this condition exists. However, aliasing is possible in OpenGL ES Shading Language 1.00 vertex shaders." Taking in to account what different versions of OpenGL and OpenGL ES specs say about aliasing: - It is allowed only on vertex shader input attributes in OpenGL (2.0 and above) and OpenGL ES 2.0. - It is explictly disallowed in OpenGL ES 3.0. Fixes Khronos CTS failing test: explicit_attrib_location_vertex_input_aliased.test See more details about this at below mentioned khronos bug. V2: Fix the case where location exceeds the maximum allowed attribute location. V3: Simplify the condition added in V2. Signed-off-by: Anuj Phogat <[email protected]> Cc: "9.2 10.0 10.1" <[email protected]> Bugzilla: Khronos #9609 Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix copy-paste error in linker_warning()Anuj Phogat2014-04-161-1/+1
| | | | | | Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Drop do_common_optimization's max_unroll_iterations parameter.Kenneth Graunke2014-04-111-3/+1
| | | | | | | | | | | | Now that we pass in gl_shader_compiler_options, it makes sense to just use options->MaxUnrollIterations, rather than passing a separate parameter. Half of the invocations already passed options->MaxUnrollIterations, while the other half passed in a hardcoded value of 32. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Pass ctx->Const.NativeIntegers to do_common_optimization().Kenneth Graunke2014-04-081-1/+3
| | | | | | | | | | | The next few patches will introduce an optimization that only works when integers are not represented as floating point values. v2: Re-word-wrap a line, as requested by Ian Romanick. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Rewrite unrolled link_invalidate_variable_locations calls as a loopIan Romanick2014-03-121-11/+4
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/linker: produce gl_shader_program Geom.InvocationsJordan Justen2014-02-201-0/+18
| | | | | | | | | | Grab the parsed invocation count, check for consistency during linking, and finally save the result in gl_shader_program Geom.Invocations. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Fix condition to generate shader link errorAnuj Phogat2014-02-181-4/+5
| | | | | | | | | | | | | | | | | | | GL_ARB_ES2_compatibility doesn't say anything about shader linking when one of the shaders (vertex or fragment shader) is absent. So, the extension shouldn't change the behavior specified in GLSL specification. Tested the behavior on proprietary linux drivers of NVIDIA and AMD. Both of them allow linking a version 100 shader program in OpenGL context, when one of the shaders is absent. Makes following Khronos CTS tests to pass: successfulcompilevert_linkprogram.test successfulcompilefrag_linkprogram.test Cc: [email protected] Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Count and check image resources.Francisco Jerez2014-02-121-0/+41
| | | | | | | v2: Add comment about the reason why image variables take up space from the default uniform block. Reviewed-by: Paul Berry <[email protected]>
* glsl/cs: Prohibit mixing of compute and non-compute shaders.Paul Berry2014-02-051-0/+7
| | | | | | | Fixes piglit test: spec/ARB_compute_shader/linker/mix_compute_and_non_compute Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Handle compute shader local size during linking.Paul Berry2014-02-051-0/+64
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl/cs: Change some linker loops to use MESA_SHADER_FRAGMENT as a bound.Paul Berry2014-02-051-4/+4
| | | | | | | | | Linker loops that iterate through all the stages in the pipeline need to use MESA_SHADER_FRAGMENT as a bound, so that we can add an additional MESA_SHADER_COMPUTE stage, without it being erroneously included in the pipeline. Reviewed-by: Matt Turner <[email protected]>
* glsl/linker: Refactor in preparation for adding more shader stages.Paul Berry2014-01-211-75/+41
| | | | | | | | | | | | | Rather than maintain separately named arrays and counts for vertex, geometry, and fragment shaders, just maintain these as arrays indexed by the gl_shader_type enum. v2: When there is neither a vertex nor a geometry shader, set prog->LastClipDistanceArraySize = 0, and clarify that the values is not used. Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Match unnamed record types across stages.Grigori Goronzy2014-01-211-0/+4
| | | | | | | | | | | | | | Unnamed record types are assigned to separate types per stage, e.g. if uniform struct { ... } a; is defined in both vertex and fragment shader, two separate types will result with different names. When linking the shader, this results in a type conflict. However, there is no reason why this should not be allowed according to GLSL specifications. Compare and match record types when linking shader stages to avoid this conflict. Reviewed-by: Matt Turner <[email protected]>
* glsl: Use a new foreach_two_lists macro for walking two lists at once.Kenneth Graunke2014-01-131-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When handling function calls, we often want to walk through the list of formal parameters and list of actual parameters at the same time. (Both are guaranteed to be the same length.) Previously, we used a pattern of: exec_list_iterator 1st_iter = <1st list>.iterator(); foreach_iter(exec_list_iterator, 2nd_iter, <2nd list>) { ... 1st_iter.next(); } This was awkward, since you had to manually iterate through one of the two lists. This patch introduces a foreach_two_lists macro which safely walks through two lists at the same time, so you can simply do: foreach_two_lists(1st_node, <1st list>, 2nd_node, <2nd list>) { ... } v2: Rename macro from foreach_list2 to foreach_two_lists, as suggested by Ian Romanick. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Convert piles of foreach_iter to the newer foreach_list macro.Kenneth Graunke2014-01-131-5/+4
| | | | | | | | | | | | | foreach_iter and exec_list_iterators have been deprecated for some time now; we just hadn't ever bothered to convert code to the newer foreach_list and foreach_list_safe macros. In these cases, we aren't editing the list, so we can use foreach_list rather than foreach_list_safe. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Index into ctx->Const.Program[] rather than using ad-hoc code.Paul Berry2014-01-091-35/+8
| | | | | Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: replace ctx->Const.{Vertex,Fragment,Geomtery}Program with an array.Paul Berry2014-01-091-12/+12
| | | | | | | | | | | | | | | | | | | | These are replaced with ctx->Const.Program[MESA_SHADER_{VERTEX,FRAGMENT,GEOMETRY}]. In patches to follow, this will allow us to replace a lot of ad-hoc logic with a variable index into the array. With the exception of the changes to mtypes.h, this patch was generated entirely by the command: find src -type f '(' -iname '*.c' -o -iname '*.cpp' -o -iname '*.py' \ -o -iname '*.y' ')' -print0 | xargs -0 sed -i \ -e 's/Const\.VertexProgram/Const.Program[MESA_SHADER_VERTEX]/g' \ -e 's/Const\.GeometryProgram/Const.Program[MESA_SHADER_GEOMETRY]/g' \ -e 's/Const\.FragmentProgram/Const.Program[MESA_SHADER_FRAGMENT]/g' Suggested-by: Brian Paul <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Use gl_shader::Stage instead of gl_shader::Type where possible.Paul Berry2014-01-081-8/+8
| | | | | | | | | | | | | | | | | | | | | This reduces confusion since gl_shader::Type is sometimes GL_SHADER_PROGRAM_MESA but is more frequently GL_SHADER_{VERTEX,GEOMETRY,FRAGMENT}. It also has the advantage that when switching on gl_shader::Stage, the compiler will alert if one of the possible enum types is unhandled. Finally, many functions in src/glsl (especially those dealing with linking) already use gl_shader_stage to represent pipeline stages; using gl_shader::Stage in those functions avoids the need for a conversion. Note: in the process I changed _mesa_write_shader_to_file() so that if it encounters an unexpected shader stage, it will use a file suffix of "????" rather than "geom". Reviewed-by: Brian Paul <[email protected]> v2: Split from patch "mesa: Store gl_shader_stage enum in gl_shader objects." Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Clean up nomenclature for pipeline stages.Paul Berry2014-01-081-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we had an enum called gl_shader_type which represented pipeline stages in the order they occur in the pipeline (i.e. MESA_SHADER_VERTEX=0, MESA_SHADER_GEOMETRY=1, etc), and several inconsistently named functions for converting between it and other representations: - _mesa_shader_type_to_string: gl_shader_type -> string - _mesa_shader_type_to_index: GLenum (GL_*_SHADER) -> gl_shader_type - _mesa_program_target_to_index: GLenum (GL_*_PROGRAM) -> gl_shader_type - _mesa_shader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string This patch tries to clean things up so that we use more consistent terminology: the enum is now called gl_shader_stage (to emphasize that it is in the order of pipeline stages), and the conversion functions are: - _mesa_shader_stage_to_string: gl_shader_stage -> string - _mesa_shader_enum_to_shader_stage: GLenum (GL_*_SHADER) -> gl_shader_stage - _mesa_program_enum_to_shader_stage: GLenum (GL_*_PROGRAM) -> gl_shader_stage - _mesa_progshader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string In addition, MESA_SHADER_TYPES has been renamed to MESA_SHADER_STAGES, for consistency with the new name for the enum. Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename the "target" field of _mesa_glsl_parse_state and the "target" parameter of _mesa_shader_stage_to_string to "stage". Reviewed-by: Brian Paul <[email protected]>
* mesa: Improve static error checking of arrays sized by MESA_SHADER_TYPES.Paul Berry2013-12-301-4/+10
| | | | | | | | | | | | | | | | | | | | | This patch replaces the following pattern: foo bar[MESA_SHADER_TYPES] = { ... }; With: foo bar[] = { ... }; STATIC_ASSERT(Elements(bar) == MESA_SHADER_TYPES); This way, when a new shader type is added in a future version of Mesa, we will get a compile error to remind us that the array needs to be updated. Reviewed-by: Brian Paul <[email protected]>
* glsl: Remove extraneous shader_type argument from analyze_clip_usage().Paul Berry2013-12-301-4/+5
| | | | | | | | This argument was carrying the name of the shader target (as a string). We can get this just as easily by calling _mesa_shader_enum_to_string(). Reviewed-by: Brian Paul <[email protected]>
* glsl: Get rid of hardcoded arrays of shader target names.Paul Berry2013-12-301-10/+6
| | | | | | | We already have a function for converting a shader type index to a string: _mesa_shader_type_to_string(). Reviewed-by: Brian Paul <[email protected]>
* Rename overloads of _mesa_glsl_shader_target_name().Paul Berry2013-12-301-1/+1
| | | | | | | | | | | | Previously, _mesa_glsl_shader_target_name() had an overload for GLenum and an overload for the gl_shader_type enum, each of which behaved differently. However, since GLenum is a synonym for unsigned int, and unsigned ints are often used in place of gl_shader_type (e.g. in loop indices), there was a big risk of calling the wrong overload by mistake. This patch gives the two overloads different names so that it's always clear which one we mean to call. Reviewed-by: Brian Paul <[email protected]>
* glsl: move variables in to ir_variable::data, part IITapani Pälli2013-12-121-46/+47
| | | | | | | | | | | | | This patch moves following bitfields and variables to the data structure: explicit_location, explicit_index, explicit_binding, has_initializer, is_unmatched_generic_inout, location_frac, from_named_ifc_block_nonarray, from_named_ifc_block_array, depth_layout, location, index, binding, max_array_access, atomic Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: move variables in to ir_variable::data, part ITapani Pälli2013-12-121-14/+14
| | | | | | | | | | This patch moves following bitfields in to the data structure: used, assigned, how_declared, mode, interpolation, origin_upper_left, pixel_center_integer Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: introduce data section to ir_variableTapani Pälli2013-12-121-3/+3
| | | | | | | | Data section helps serialization and cloning of a ir_variable. This patch includes the helper bits used for read only ir_variables. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add ir support for `sample` qualifier; adjust compiler and linkerChris Forbes2013-12-071-0/+6
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: Simplify the built-in function linking code.Kenneth Graunke2013-12-011-20/+22
| | | | | | | | | | | | | | | | | | Previously, we stored an array of up to 16 additional shaders to link, as well as a count of how many each shader actually needed. Since the built-in functions rewrite, all the built-ins are stored in a single shader. So all we need is a boolean indicating whether a shader needs to link against built-ins or not. During linking, we can avoid creating the temporary array if none of the shaders being linked need built-ins. Otherwise, it's simply a copy of the array that has one additional element. This is much simpler. This patch saves approximately 128 bytes of memory per gl_shader object. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Validate IR just before reparenting.Paul Berry2013-11-261-0/+5
| | | | | | | | | | | | | | | | | If reparent_ir() is called on invalid IR, then there's a danger that it will fail to reparent all of the necessary nodes. For example, if the IR contains an ir_dereference_variable which refers to an ir_variable that's not in the tree, that ir_variable won't get reparented, resulting in subtle use-after-free bugs once the non-reparented nodes are freed. (This is exactly what happened in the bug fixed by the previous commit). This patch makes this kind of bug far easier to track down, by transforming it from a use-after-free bug into an explicit IR validation error. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix interstage uniform interface block link error detection.Paul Berry2013-11-211-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we checked for interstage uniform interface block link errors in validate_interstage_interface_blocks(), which is only called on pairs of adjacent shader stages. Therefore, we failed to detect uniform interface block mismatches between non-adjacent shader stages. Before the introduction of geometry shaders, this wasn't a problem, because the only supported shader stages were vertex and fragment shaders, therefore they were always adjacent. However, now that we allow a program to contain vertex, geometry, and fragment shaders, that is no longer the case. Fixes piglit test "skip-stage-uniform-block-array-size-mismatch". Cc: "10.0" <[email protected]> v2: Rename validate_interstage_interface_blocks() to validate_interstage_inout_blocks() to reflect the fact that it no longer validates uniform blocks. Reviewed-by: Jordan Justen <[email protected]> v3: Make validate_interstage_inout_blocks() skip uniform blocks. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Linker support for ARB_shader_atomic_counters.Francisco Jerez2013-11-071-1/+20
| | | | | | | | | | | | | | | v2: Add comments on the purpose of the auxiliary data structures. Check for atomic counter overlaps. Use the contains_atomic() convenience method. Add static assert with the number of expected shader stages. v3: Don't resize atomic arrays. v4: Add comment on the reason why we don't resize atomic counter arrays. Use 'strcmp(...) == 0' instead of '!strcmp(...)'. v5 (idr): Don't use STL in the linker. Signed-off-by: Francisco Jerez <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Make mode_string function globally availableIan Romanick2013-10-301-23/+0
| | | | | | | | | | | | | | | | | | 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: Add check for unsized arrays to glsl typesTimothy Arceri2013-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | 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/gs: Fix transform feedback of gl_ClipDistance.Paul Berry2013-10-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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: Simplify the interface to link_invalidate_variable_locationsIan Romanick2013-10-221-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Modify interface to link_invalidate_variable_locationsIan Romanick2013-10-221-5/+5
| | | | | | | | | | | 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/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: Modify array_sizing_visitor to handle unnamed interface blocks.Paul Berry2013-10-091-0/+86
| | | | | | | | | | | | | | | | | | | 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/linker: Modify array_sizing_visitor to handle named interface blocks.Paul Berry2013-10-091-6/+71
| | | | | | | | | | | | | | | | | 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]>