summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_function.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: move variables in to ir_variable::data, part ITapani Pälli2013-12-121-1/+1
| | | | | | | | | | 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: Skip unavailable built-ins when matching signatures.Kenneth Graunke2013-09-091-0/+8
| | | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Pass _mesa_glsl_parse_state into matching_signature and such.Kenneth Graunke2013-09-091-4/+7
| | | | | | | | | | | | | | | | | | | | | | | During compilation, we'll use this to determine built-in availability. The plan is to have a single shader containing every built-in in every version of the language, but filter out the ones that aren't actually available to the shader being compiled. At link time, we don't actually need this filtering capability: we've already imported prototypes for every built-in that the shader actually calls, and they're flagged as is_builtin(). The linker doesn't import any additional prototypes, so it won't pull in any unavailable built-ins. When resolving prototypes to function definitions, the linker ensures the values of is_builtin() match, which means that a shader can't trick the linker into importing the body of an unavailable built-in by defining a suspiciously similar prototype. In other words, during linking, we can just pass in NULL. It will work out fine. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Eliminate ambiguity between function ins/outs and shader ins/outsPaul Berry2013-01-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces the three ir_variable_mode enums: - ir_var_in - ir_var_out - ir_var_inout with the following five: - ir_var_shader_in - ir_var_shader_out - ir_var_function_in - ir_var_function_out - ir_var_function_inout This eliminates a frustrating ambiguity: it used to be impossible to tell whether an ir_var_{in,out} variable was a shader in/out or a function in/out without seeing where the variable was declared in the IR. This complicated some optimization and lowering passes, and would have become a problem for implementing varying structs. In the lisp-style serialization of GLSL IR to strings performed by ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in", "out", and "inout" for function parameters, to avoid introducing code churn to the src/glsl/builtins/ir/ directory. Note: a couple of comments in the code seemed to indicate that we were planning for a possible future in which geometry shaders could have shader-scope inout variables. Our GLSL grammar rejects shader-scope inout variables, and I've been unable to find any evidence in the GLSL standards documents (or extensions) that this will ever be allowed, so I've eliminated these comments. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Demote 'type' from ir_instruction to ir_rvalue and ir_variable.Kenneth Graunke2012-04-021-1/+1
| | | | | | | | | | | | | Variables have types, expression trees have types, but statements don't. Rather than have a nonsensical field that stays NULL in the base class, just move it to where it makes sense. Fix up a few places that lazily used ir_instruction even though they actually knew the particular subclass. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a new matching_signature() variant that returns exact/inexact.Kenneth Graunke2011-11-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | When matching function signatures across multiple linked shaders, we often want to see if the current shader has _any_ match, but also know whether or not it was exact. (If not, we may want to keep looking.) This could be done via the existing mechanisms: sig = f->exact_matching_signature(params); if (sig != NULL) { exact = true; } else { sig = f->matching_signature(params); exact = false; } However, this requires walking the list of function signatures twice, which also means walking each signature's formal parameter lists twice. This could be rather expensive. Since matching_signature already internally knows whether a match was exact or not, we can just return it to get that information for free. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: silence warning about trailing comma in enum listBrian Paul2011-08-081-1/+1
|
* glsl: Remove duplicate commentChad Versace2011-08-011-8/+0
| | | | | | | Remove duplicate doxgen comment for ir_function.cpp:parameter_lists_match(). Signed-off-by: Chad Versace <[email protected]>
* glsl: Clarify ir_function::matching_sigature()Chad Versace2011-07-301-20/+33
| | | | | | | | | | | The function used a variable named 'score', which was an outright lie. A signature matches or it doesn't; there is no fuzzy scoring. Change the return type of parameter_lists_match() to an enum, and let ir_function::matching_sigature() switch on that enum. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Remove ir_function.cpp:type_compare()Chad Versace2011-07-301-61/+0
| | | | | | | | | The function is no longer used and has been replaced by glsl_type::can_implicitly_convert_to(). Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Fix implicit conversions in non-constructor function callsChad Versace2011-07-301-17/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Context ------- In ast_function_expression::hir(), parameter_lists_match() checks if the function call's actual parameter list matches the signature's parameter list, where the match may require implicit conversion of some arguments. To check if an implicit conversion exists between individual arguments, type_compare() is used. Problems -------- type_compare() allowed the following illegal implicit conversions: bool -> float bvecN -> vecN int -> uint ivecN -> uvecN uint -> int uvecN -> ivecN Change ------ type_compare() is buggy, so replace it with glsl_type::can_be_implicitly_converted_to(). This comprises a rewrite of parameter_lists_match(). Fixes piglit:spec/glsl-1.20/compiler/built-in-functions/outerProduct-bvec*.vert Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Reject ambiguous function calls (multiple inexact matches).Kenneth Graunke2011-07-111-6/+27
| | | | | | | | | | | | | | | | | | | According to the GLSL 1.20 specification, "it is a semantic error if there are multiple ways to apply [implicit] conversions [...] such that the call can be made to match multiple signatures." Fixes a regression caused by 60eb63a855cb89962f2d5bb91e238ff2d1ab8702, which implemented the wrong policy of finding a "closest" match. However, this is not a revert, since the original code failed to continue looking for an exact match once it found two inexact matches. It's OK to have multiple inexact matches if there's also an exact match. NOTE: This is a candidate for the 7.10 and 7.11 branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38971 Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Suppress warning from matching_signature change.Eric Anholt2011-07-061-1/+1
| | | | | gcc isn't smart enough to see that we only look at matched_score after we've initialized it (because match != NULL happens at the same time)
* glsl: Find the "closest" signature when there are multiple matches.Kenneth Graunke2011-06-291-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, ir_function::matching_signature had a fatal bug: if a function had more than one non-exact match, it would simply return NULL. This occured, for example, when looking for max(uvec3, uvec3): - max(vec3, vec3) -> score 1 (found first) - max(ivec3, ivec3) -> score 1 (found second...used to return NULL here) - max(uvec3, uvec3) -> score 0 (exact match...the right answer) This did not occur for max(ivec3, ivec3) since the second match found was an exact match. The new behavior is to return a match with the lowest score. If there is an exact match, that will be returned. Otherwise, a match with the least number of implicit conversions is chosen. Fixes piglit tests max-uvec3.vert and glsl-inexact-overloads.shader_test. NOTE: This is a candidate for the 7.10 and 7.11 branches. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Introduce a new "const_in" variable mode.Kenneth Graunke2011-01-311-0/+1
| | | | | | | | This annotation is for an "in" function parameter for which it is only legal to pass constant expressions. The only known example of this, currently, is the textureOffset functions. This should never be used for globals.
* glsl: Remove GLSL_TYPE_FUNCTION define.Kenneth Graunke2010-11-151-1/+0
| | | | | | | Functions are not first class objects in GLSL, so there is never a value of function type. No code actually used this except for one function which asserted it shouldn't occur. One comment mentioned it, but was incorrect. So we may as well remove it entirely.
* glsl: Silence uninitialized variable warning.Vinson Lee2010-08-211-0/+3
| | | | | | | i686-apple-darwin10-gcc-4.2.1 generated the following warning. warning: 'score' may be used uninitialized in this function GCC 4.4.3 on Linux didn't generate the above warning.
* glsl2: Fix spelling of "sentinel."Eric Anholt2010-07-291-5/+5
|
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-201-0/+1
| | | | | | | | | | | | | | | | | This is quite a large patch because breaking it into smaller pieces would result in the tree being intermitently broken. The big changes are: * Add the ir_var_temporary variable mode * Change the ir_variable constructor to take the mode as a parameter and correctly specify the mode for all ir_varables. * Change the linker to not cross validate ir_var_temporary variables. * Change the linker to pull all ir_var_temporary variables from global scope into 'main'.
* glsl2: Explicitly walk lists in ir_function::parameter_lists_matchIan Romanick2010-07-191-23/+21
| | | | | | Give ir_function::parameter_lists_match_exist similar treatment. Make the parameters const, and propogate the constness as far as it will trivially go.
* ir_function: Make matching_signature not return constIan Romanick2010-07-121-1/+1
| | | | | | | The linker needs to use this function to get specific function signatures, but it also needs to modify the returned signature. Since this method isn't itself const (i.e., const this pointer), there is no value in making a const and non-const version.
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+225