summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_functions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Basic support for built-in intrinsics.Francisco Jerez2013-10-291-6/+10
| | | | | | | | | | | | | | | | | 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: 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: Hide many classes local to individual .cpp files in anon namespaces.Eric Anholt2013-09-231-0/+3
| | | | | | | | This gives the compiler the chance to inline and not export class symbols even in the absence of LTO. Saves about 60kb on disk. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Pass _mesa_glsl_parse_state into matching_signature and such.Kenneth Graunke2013-09-091-2/+3
| | | | | | | | | | | | | | | | | | | | | | | 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: Convert ir_function_signature::is_builtin to a method.Kenneth Graunke2013-09-091-2/+2
| | | | | | | | | | | A signature is a built-in if and only if builtin_info != NULL, so we don't actually need a separate flag bit. Making a boolean-valued method allows existing code to ask the same question while not worrying about the internal representation. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: propagate max_array_access through function callsDominik Behr2013-09-051-0/+32
| | | | | | | | | | | | Fixes a bug where if an uniform array is passed to a function the accesses to the array are not propagated so later all but the first vector of the uniform array are removed in parcel_out_uniform_storage resulting in broken shaders and out of bounds access to arrays in brw::vec4_visitor::pack_uniform_registers. Cc: [email protected] Reviewed-and-Tested-by: Matt Turner <[email protected]> Signed-off-by: Dominik Behr <[email protected]>
* glsl: Remove ir_call::get_callee() and set_callee().Kenneth Graunke2012-04-021-3/+3
| | | | | | | | | | | | | Previously, set_callee() performed some assertions about the type of the ir_call; protecting the bare pointer ensured these checks would be run. However, ir_call no longer has a type, so the getter and setter methods don't actually do anything useful. Remove them in favor of accessing callee directly, as is done with most other fields in our IR. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: When linking, emit functions at the tail of the final linked program.Paul Berry2011-08-081-2/+4
| | | | | | | | | | | | | | | | | | | | | When link_functions.cpp adds a new function to the final linked program, it needs to add it after any global variable declarations that the function refers to, otherwise the IR will be invalid (because variable declarations must occur before variable accesses). The easiest way to do that is to have the linker emit functions to the tail of the final linked program. The linker used to emit functions to the head of the final linked program, in an effort to keep callees sorted before their callers. However, this was not reliable: it didn't work for functions declared or defined in the same compilation unit as main, for diamond-shaped patterns in the call graph, or for some obscure cases involving overloaded functions. And no code currently relies on this sort order. No Piglit regressions with i965 Ironlake. Reviewed-by: Kenneth Graunke <[email protected]>
* linker: Make linker_error set LinkStatus to falseIan Romanick2011-08-021-2/+2
| | | | | | | | | | | | Remove the other places that set LinkStatus to false since they all immediately follow a call to linker_error. The function linker_error was previously known as linker_error_printf. The name was changed because it may seem surprising that a printf function will set an error flag. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Only over-ride built-ins when a prototype has been seenIan Romanick2011-07-171-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | The GLSL spec says: "If a built-in function is redeclared in a shader (i.e., a prototype is visible) before a call to it, then the linker will only attempt to resolve that call within the set of shaders that are linked with it." This patch enforces this behavior. When a function call is processed a flag is set in the ir_call to indicate whether the previously seen prototype is the built-in or not. At link time a call will only bind to an instance of a function that matches the "want built-in" setting in the ir_call. This has the odd side effect that first call to abs() in the shader below will call the built-in and the second will not: float foo(float x) { return abs(x); } float abs(float x) { return -x; } float bar(float x) { return abs(x); } This seems insane, but it matches what the spec says. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31744
* linker: Add imported functions to the linked IRIan Romanick2011-03-081-1/+7
| | | | | | Fixes piglit test glsl-function-chain16 and bugzilla #34203. NOTE: This is a candidate for stable release branches.
* Use C-style system headers in C++ code to avoid issues with std:: namespaceIan Romanick2011-02-211-4/+0
|
* linker: Propagate max_array_access while linking functionsIan Romanick2011-01-251-0/+12
| | | | | | | | | Update the max_array_access of a global as functions that use that global are pulled into the linked shader. Fixes piglit test glsl-fs-implicit-array-size-01 and bugzilla #33219. NOTE: This is a candidate for the 7.9 and 7.10 branches.
* glsl, i965: Remove unnecessary talloc includes.Kenneth Graunke2011-01-211-4/+0
| | | | These are already picked up by ir.h or glsl_types.h.
* glsl: Make the symbol table's add_variable just use the variable's name.Eric Anholt2010-11-291-1/+1
|
* linker: Require an exact matching signature when looking for prototypes.Kenneth Graunke2010-08-301-1/+1
| | | | | | | Fixes piglit test glsl-override-builtin. The linker incorrectly found the prototype for the float signature, rather than adding a new prototype with the int return type. This caused ir_calls with type int to have their callees set to the float signature, triggering an assert.
* glsl: Include main/core.h.Chia-I Wu2010-08-241-1/+1
| | | | Make glsl include only main/core.h from core mesa.
* glsl2: Make the clone() method take a talloc context.Eric Anholt2010-08-041-3/+3
| | | | | | | In most cases, we needed to be reparenting the cloned IR to a different context (for example, to the linked shader instead of the unlinked shader), or optimization before the reparent would cause memory usage of the original object to grow and grow.
* glsl2: Give the path within src/mesa/ for headers instead of relying on -I.Aras Pranckevicius2010-08-021-1/+1
|
* glsl2: Update the callee pointer of calls to newly-linked-in functions.Eric Anholt2010-07-301-0/+2
| | | | | | Otherwise, ir_function_inlining will see the body of the function from the unlinked version of the shader, which won't have had the lowering passes done on it or linking's variable remapping.
* linker: Recursively resolve function calls in imported functionsIan Romanick2010-07-191-3/+46
|
* linker: look up function signatures during linking instead of using calleeIan Romanick2010-07-191-24/+59
| | | | | | | Instead of using ir_call::callee, search for the signature in the linked shader. This will allow resolving calls from functions imported from other shaders. The ir_call::callee pointer in the imported function will still reference a signature in the original shader.
* linker: Pull find_matching_signature out of call_link_visitorIan Romanick2010-07-191-21/+27
| | | | | | The list of shaders to search needs to be provided as an explicit parameter to support coming changes. At that point there is no reason for it to be in the class. Also, fix some of the 'const' decorators.
* linker: First bits of intrastage, intershader function linkingIan Romanick2010-07-191-0/+176
This handles the easy case of linking a function in a different compilation unit that doesn't call any functions or reference any global variables.