summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Implement overload resolution for ARB_gpu_shader5Chris Forbes2014-06-041-0/+71
| | | | | | | V3: Move spec citation into the code. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add support for comparing function parameter conversionsChris Forbes2014-06-041-3/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | The ARB_gpu_shader5 spec says: "To determine whether the conversion for a single argument in one match is better than that for another match, the following rules are applied, in order: 1. An exact match is better than a match involving any implicit conversion. 2. A match involving an implicit conversion from float to double is better than a match involving any other implicit conversion. 3. A match involving an implicit conversion from either int or uint to float is better than a match involving an implicit conversion from either int or uint to double. If none of the rules above apply to a particular pair of conversions, neither conversion is considered better than the other." V3: Add spec citation, including oddball difference between gs5 and GLSL 4.0; comment a bit better as per Jordan's suggestions. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Build a list of inexact function matchesChris Forbes2014-06-041-11/+32
| | | | | | | | | This will facilitate GLSL 4.0 / ARB_gpu_shader5's enhanced overload resolution rules, and also possibly better error reporting for ambiguous function calls. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Allow int -> uint implicit conversions on function parametersChris Forbes2014-06-041-3/+16
| | | | | | | | | V2: Fix crashes during linking, where the parse state is NULL. In this case, all required checks have already been done, so we assume the extension is enabled. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Pass parse state to can_implicitly_convert_to()Chris Forbes2014-06-044-6/+8
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Pass parse state to parameter_lists_match()Chris Forbes2014-06-041-2/+3
| | | | | | | | The available implicit conversions depend on the GLSL version we're compiling. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for int -> uint implicit conversionsChris Forbes2014-06-041-0/+8
| | | | | | | This is required for ARB_gpu_shader5. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Clean up apply_implicit_conversionChris Forbes2014-06-041-27/+31
| | | | | | | | | | | | | | | We're about to add new implicit conversions, first for ARB_gpu_shader5, and then later for ARB_gpu_shader_fp64. Pull out the opcode determination into its own function, and get rid of the bool -> float case that could never be hit anyway [since it fails the is_numeric() check]. V2: Retain the vector width mangling. It turns out this is necessary for the conversions done (and then thrown away) when determining the return type of arithmetic operators. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow `precise` as a parameter qualifierChris Forbes2014-06-041-2/+10
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Disallow `precise` redeclarations of vars from outer scopesChris Forbes2014-06-041-0/+9
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add support for `precise` redeclarationsChris Forbes2014-06-044-7/+47
| | | | | | | | This works like glsl-1.20+'s invariant redeclarations, but with fewer restrictions, since `precise` is allowed on pretty much anything. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: add support for `precise` in type_qualifierChris Forbes2014-06-045-8/+48
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: remove outdated comment, move sample to correct blockChris Forbes2014-06-041-3/+3
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Make most ir_instruction::as_subclass() functions non-virtual.Matt Turner2014-06-031-109/+52
| | | | | | | | | | | | | | | | | | | | | | | | There are several common ways to check whether an object is a particular subclass: dynamic_cast<>, the as_subclass() pattern, or explicit enum tags. We originally used the virtual as_subclass methods, but later added enum tags as they are much nicer for debugging. Since we have the enum tags, we don't necessarily need to use virtual functions to implement the as_subclass() methods. We can just check the tag and return the pointer or NULL. This saves 18 entries in the vtable, and instead of two pointer dereferences per as_subclass() call most are only three inline instructions. Compile time of sam3/112.frag (the longest compile in a recent shader-db run) is reduced by 5% from 348 to 329 ms (n=500). perf stat of this workload shows: 24.14% reduction in iTLB-loads: 285,543 -> 216,606 42.55% reduction in iTLB-load-misses: 18,785 -> 10,792 Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: Move ir_type_unset to end of enumeration.Matt Turner2014-06-032-7/+3
| | | | | | | | Now that the constructors set a type, ir_type_unset is not very useful. Move it to the end of the enum (specifically out of position 0) so that enums checks for dereferences and rvalues can save an instruction. Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: Reorder ir_type_* enum for easier comparisons.Matt Turner2014-06-031-7/+7
| | | | | | | | Makes checking whether an object is an ir_dereference, an ir_rvalue, or an ir_jump simpler. Since ir_dereference is a subclass or ir_rvalue, list its subtypes first so that they can both generate nice code. Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: Remove useless call to as_rvalue().Matt Turner2014-06-031-1/+1
| | | | | | The type returned by hir() is already an ir_rvalue pointer. Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: Set ir_instruction::ir_type in the base class constructorIan Romanick2014-06-032-54/+57
| | | | | | | | | | | | This has the added perk that if you forget to set ir_type in the constructor of a new subclass (or a new constructor of an existing subclass) the compiler will tell you... instead of relying on ir_validate or similar run-time detection. Reviewed-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Ian Romanick <[email protected]>
* scons: add common.c as part of glcpp buildTapani Pälli2014-05-301-1/+1
| | | | | | | | to have _mesa_error_no_memory function available Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79440 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glcpp: link with tests/common.cTapani Pälli2014-05-301-0/+1
| | | | | | | So that prog_hash_table can use _mesa_error_no_memory function. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: Add null check in loop_analysis.cppJuha-Pekka Heikkila2014-05-301-2/+4
| | | | | | | Check return value from hash_table_find before using it as a pointer Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/tests: remove generated tests from the repoConnor Abbott2014-05-2849-696/+2
| | | | | | | | They were made unneccesary by the last commit. Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/tests: call create_test_cases.py in optimization-testConnor Abbott2014-05-281-0/+8
| | | | | | | | | | | | | | This way, when someone modifies create_test_cases.py and forgets to commit their changes again, people will notice. v2: make sure we parse the right directories and check for existance the right way. v3 (Ken): Use $PYTHON2 instead of calling python directly. Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/tests/lower_jumps: fix generated sexpr's for loopsConnor Abbott2014-05-281-1/+1
| | | | | | | | | | | | | | In 088494aa (as well as other commits in the series) Paul Berry modified the tests for lower_jumps to account for the fact that the s-expression for the loop IR instruction changed from (loop () () () () (statements...)) to (loop (statements...)), but he forgot to update create_test_cases.py which he used to create the tests. Fix that, so that now create_test_cases.py is synced with the generated tests. Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: be more consistent about printing constantsConnor Abbott2014-05-2823-48/+40
| | | | | | | | | | | | Make sure that we print the same number of digits when printing 0.0 as any other floating-point number. This will make generating expected output files for tests easier. To avoid breaking "make check," update the generated tests for lower_jumps before the next commit which will bring create_test_cases.py in line with them. Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: replace strncmp("gl_") calls with new is_gl_identifier() helperBrian Paul2014-05-285-9/+17
| | | | | | Makes things a little easier to read. Reviewed-by: Ian Romanick <[email protected]>
* glsl: fix use-after free bug/crash in ast_declarator_list::hir()Brian Paul2014-05-281-1/+5
| | | | | | | | | | | | | | The call to get_variable_being_redeclared() may delete 'var' so we can't reference var->name afterward. We fix that by examining the var's name before making that call. Fixes valgrind warnings and possible crash when running the piglit tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-in-param.shader_test test (and probably others). Cc: "10.1 10.2" <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add C-callable fprint_ir function.Matt Turner2014-05-152-0/+10
| | | | | Acked-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: simplify the M_PI*f macros, fixes build on OpenBSDJonathan Gray2014-05-131-5/+3
| | | | | | | | | | | | | | | | | | The M_PI*f macros used a preprocessor paste to append 'f' to M_PI defines, which works if the values are only numbers but breaks on OpenBSD where M_PI definitions have casts and brackets to meet requirements of a future version of POSIX, http://austingroupbugs.net/view.php?id=801 http://austingroupbugs.net/view.php?id=828 Simplify the M_PI*f macros by using casts directly in the defines as suggested by Kenneth Graunke. Cc: "10.2" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78665 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Jonathan Gray <[email protected]>
* ralloc: Omit detailed license information about talloc.José Fonseca2014-05-131-4/+3
| | | | | | | | | | | | That information misleads source code auditing tools to think that ralloc itself is released under LGPL v3. Instead, simply state talloc is not licensed under a permissive license. v2: Use wording suggested by Kenneth. Reviewed-by: Brian Paul <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
* glsl: Do not call lhs->variable_referenced() multiple timesIago Toral Quiroga2014-05-131-3/+2
| | | | | | Instead take the result from the first call and use it where needed. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: the number of samplers is already calculated so use itTimothy Arceri2014-05-131-2/+1
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Rename linker's is_varying_varChris Forbes2014-05-101-3/+3
| | | | | | | | | | | | | Both the ast->IR and linker have functions with this name, but different behavior. Rename the linker's version to var_counts_against_varying_limit to be closer to what it is actually used for. Suggested by Ian a while back. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* linker: Fix consumer_inputs_with_locations indexingIan Romanick2014-05-072-10/+9
| | | | | | | | | | | | | | | | | | | | | In an earlier incarnation of populate_consumer_input_sets and get_matching_input, the consumer_inputs_with_locations array was indexed using the user-specified location. In that version, only user-defined varyings were included in the array. In the current incarnation, the Mesa location is used to index the array, and built-in varyings are included. This change fixes the unit test to exepect gl_ClipDistance in the array, and it resizes the arrays to actually be big enough. It's just dumb luck that the existing piglit tests use small enough locations to not stomp the stack. :( Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78258 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.2" <[email protected]> Cc: Vinson Lee <[email protected]>
* glsl: fix bogus layout qualifier warningsTapani Pälli2014-05-061-4/+7
| | | | | | | | | | Print out GL_ARB_explicit_attrib_location warnings only when parsing attribute that uses "location" qualifier. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77245 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Cc: "10.1 10.2" <[email protected]>
* mesa: Add _mesa_error_no_memory for logging out-of-memory messagesIan Romanick2014-05-023-3/+43
| | | | | | | | | | This can be called from locations that don't have a context pointer handy. This patch also adds enough infrastructure so that the unit tests for the GLSL compiler and the stand-alone compiler will build and function. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: make static constant variables "static const"Chia-I Wu2014-05-025-37/+38
| | | | | | | | | This allows them to be moved to .rodata, and allow us to be sure that they will not be modified. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add lowering passes for carry/borrowIlia Mirkin2014-05-022-0/+60
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Matt Turner <[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-024-4/+9
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Sort the list of extensionsIan Romanick2014-05-022-62/+85
| | | | | | | | ARB, OES, then everything else. If there's ever a KHR shading language extension, it should go between ARB and OES. Signed-off-by: Ian Romanick <[email protected]> Acked-by: Eric Anholt <[email protected]>
* mesa: Remove support for desktop OpenGL GL_EXT_separate_shader_objectsIan Romanick2014-05-021-6/+1
| | | | | | | | | | | | | | | | I don't know of any applications that actually use it. Now that Mesa supports GL_ARB_separate_shader_objects in all drivers, this extension is just cruft. The entrypoints for the extension remain in the XML. This is done so that a new libGL will continue to provide dispatch support for old drivers that try to expose this extension. Future patches will add OpenGL ES GL_EXT_separate_shader_objects, but that's a different thing. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa/sso: Enable GL_ARB_separate_shader_objects by defaultIan Romanick2014-05-022-4/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Modify cross_validate_outputs_to_inputs to match using explicit ↵Ian Romanick2014-05-022-20/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | locations This will be used for GL_ARB_separate_shader_objects. That extension not only allows separable shaders to rendezvous by location, but it also allows traditionally linked shaders to rendezvous by location. The spec says: 36. How does the behavior of input/output interface matching differ between separable programs and non-separable programs? RESOLVED: The rules for matching individual variables or block members between stages are identical for separable and non-separable programs, with one exception -- matching variables of different type with the same location, as discussed in issue 34, applies only to separable programs. However, the ability to enforce matching requirements differs between program types. In non-separable programs, both sides of an interface are contained in the same linked program. In this case, if the linker detects a mismatch, it will generate a link error. v2: Make sure consumer_inputs_with_locations is initialized when consumer is NULL. Noticed by Chia-I. v3: Rebase on removal of ir_variable::user_location. v4: Replace a (stale) FINISHME with some good explanation comments from Eric. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Sort shader I/O variables into a canonical orderIan Romanick2014-05-021-4/+74
| | | | | | | v2: Rebase on removal of ir_variable::user_location. 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-022-3/+30
| | | | Signed-off-by: Ian Romanick <[email protected]>
* linker: Allow consumer stage or producer stage to be NULLIan Romanick2014-05-021-25/+46
| | | | | | | | | When linking a separable program that contains only a fragment shader, the producer will be NULL. Similar cases will exist with geometry shaders and, eventually, tessellation shaders. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Refactor code that gets an input matching an outputIan Romanick2014-05-022-17/+114
| | | | Signed-off-by: Ian Romanick <[email protected]>
* glsl: Exit when the shader IR contains an interface block instanceIan Romanick2014-05-022-31/+63
| | | | | | | | | | | While writing the link_varyings::single_interface_input test, I discovered that populate_consumer_input_sets assumes that all shader interface blocks have been lowered to discrete variables. Since there is a pass that does this, it is a reasonable assumption. It was, however, non-obvious. Make the code fail when it encounters such a thing, and add a test to verify that behavior. Signed-off-by: Ian Romanick <[email protected]>