summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: reindent line in ast_function.cppDave Airlie2016-05-241-1/+1
| | | | | | | This fixes a warning with gcc -Wmisleading-indentation. Acked-by: Matt Turner <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Use correct mode for split components.Bas Nieuwenhuizen2016-05-241-1/+1
| | | | | | | | The mode should stay the same as the original struct. In particular, shared should not be changed to temporary. Reviewed-by: Jordan Justen <[email protected]> Signed-off-by: Bas Nieuwenhuizen <[email protected]>
* glsl/linker: dvec3/dvec4 consume twice input vertex attributesJuan A. Suarez Romero2016-05-231-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the GL 4.5 core spec, section 11.1.1 (Vertex Attributes): "A program with more than the value of MAX_VERTEX_ATTRIBS active attribute variables may fail to link, unless device-dependent optimizations are able to make the program fit within available hardware resources. For the purposes of this test, attribute variables of the type dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3, and dmat4 may count as consuming twice as many attributes as equivalent single-precision types. While these types use the same number of generic attributes as their single-precision equivalents, implementations are permitted to consume two single-precision vectors of internal storage for each three- or four-component double-precision vector." This commits makes dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3 and dmat4 consume twice as many attributes as equivalent single-precision types. v3: count doubles as consuming two attributes (Dave Airlie) v4: make reference to spec (Michael Schellenberger Costa) Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Antia Puentes <[email protected]> Signed-off-by: Juan A. Suarez Romero <[email protected]>
* glsl/parser: handle multiple layout sections with AST nodes.Dave Airlie2016-05-231-0/+2
| | | | | | | | | | | | | For geometry/compute inputs and tess control outputs, we create an AST node to keep track of some things. However if we have multiple layout sections, we don't ever link the node into the AST. This is because we create the node on the rightmost layout declaration and don't pass it back in so it gets linked at the end of the parsing of the rightmost. Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: allow layout qualifier overrides with ARB_shading_language_420packDave Airlie2016-05-231-1/+6
| | | | | | | | | | GLSL 4.20 allows overriding the layout qualifiers. This helps fix: GL45-CTS.shading_language_420pack.qualifier_override_layout Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* subroutines: handle explicit indexes properlyDave Airlie2016-05-233-15/+30
| | | | | | | | | | | | | | The code didn't deal with explicit function indexes properly. It also handed out the indexes at link time, when we really need them in the lowering pass to create the correct if ladder. So this patch moves assigning the non-explicit indexes earlier, fixes the lowering pass and the lookups to get the correct values. This fixes a few of: GL45-CTS.explicit_uniform_location.subroutine-index-* Signed-off-by: Dave Airlie <[email protected]>
* mesa/subroutines: count number subroutines properly.Dave Airlie2016-05-231-0/+1
| | | | | | | | | | | | | The code was implementing the ACTIVE_SUBROUTINE_UNIFORMS incorrectly, using the number of types not the number of uniforms. This is different than the locations as the locations may be sparsly allocated. This fixes: GL43-CTS.shader_subroutine.four_subroutines_with_two_uniforms Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/ast: for geom shaders allow stream flags in input flags.Dave Airlie2016-05-231-1/+4
| | | | | | | | | | | This fixes: GL45-CTS.shader_subroutine.subroutines_with_separate_shader_objects Since we set the stream flags earlier on all geom shaders, we shouldn't fall over later if we find one. Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: skip inactive explicit locations.Dave Airlie2016-05-231-0/+3
| | | | | | | | This fixes a crash in: GL45-CTS.explicit_uniform_location.subroutine-loc-negative-link-max-num-of-locations Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: fix subroutine uniform .length().Dave Airlie2016-05-231-0/+8
| | | | | | | | | | | | | This fixes .length() on subroutine uniform arrays, if we don't find the identifier normally, we look up the corresponding subroutine identifier instead. Fixes: GL45-CTS.shader_subroutine.arrays_of_arrays_of_uniforms GL45-CTS.shader_subroutine.arrayed_subroutine_uniforms Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: link error on too many subroutine functions.Dave Airlie2016-05-231-0/+4
| | | | | | | | This fixes: GL45-CTS.explicit_uniform_location.subroutine-index-negative-link-max-num-of-indices Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: produce a linker error for a subroutine uniform with no functions.Dave Airlie2016-05-231-0/+4
| | | | | | | | | | | If a subroutine uniform is declared with no functions backing it, that isn't legal, so we should fail to link. Fixes: GL43-CTS.shader_subroutine.subroutine_uniform_wo_matching_subroutines Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: validate subroutine types match function signature.Dave Airlie2016-05-231-0/+18
| | | | | | | | | | | This fixes: GL43-CTS.shader_subroutine.subroutines_incompatible_with_subroutine_type It just makes sure the signatures match as well as the return types. Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Guard against NULL dereferenceMark Janes2016-05-201-1/+1
| | | | | | | | | This trivially corrects mesa 3ca1c221, which introduced a check that crashes when a match is not found. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005 Fixes: piglit.spec.glsl-1_50.compiler.interface-blocks-name-reused-globally-4.vert Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: handle same struct redeclaration (v2)Dave Airlie2016-05-201-1/+6
| | | | | | | | | | | | | | | | This works around a bug in older version of UE4, where a shader defines the same structure twice. Although we aren't sure this is correct GLSL (it most likely isn't) there are enough UE4 based things out there we should deal with this. This drops the error to a warning if the struct names and contents match. v1.1: do better C++ on record_compare declaration (Rob) v2: restrict this to desktop GL only (Ian) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005 Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: attempt to match anonymous structures at linkDave Airlie2016-05-191-9/+15
| | | | | | | | | | | This is my attempt at fixing at least one of the UE4 bugs with GL4.3. If we are doing intrastage matching and hit anonymous structs, then we should do a record comparison instead of using the names. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005 Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Check that layout is non-null before dereferencing.Matt Turner2016-05-181-1/+1
| | | | | | | layout should only be null for structs, but it's checked everywhere else and confuses Coverity (CID 1358495). Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Ensure the first stage of an SSO pipeline has input locs assignedIan Romanick2016-05-181-3/+6
| | | | | | | | | | | | | | | | | | | | | Previously an SSO pipeline containing only a tessellation control shader and a tessellation evaluation shader would not get locations assigned for the TCS inputs. This would lead to assertion failures in some piglit tests, such as arb_program_interface_query-resource-query. That piglit test still fails on some tessellation related subtests. Specifically, these subtests fail: 'GL_PROGRAM_INPUT(tcs) active resources' expected 2 but got 3 'GL_PROGRAM_INPUT(tcs) max length name' expected 12 but got 16 'GL_PROGRAM_INPUT(tcs,tes) active resources' expected 2 but got 3 'GL_PROGRAM_INPUT(tcs,tes) max length name' expected 12 but got 16 'GL_PROGRAM_OUTPUT(tcs) active resources' expected 15 but got 3 'GL_PROGRAM_OUTPUT(tcs) max length name' expected 23 but got 12 Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* glsl/linker: Don't include interface name for built-in blocksIan Romanick2016-05-181-1/+2
| | | | | | | | | | | | | | Commit 11096ec introduced a regression in some piglit tests (e.g., arb_program_interface_query-resource-query). I did not notice this regression because other (unrelated) problems caused failed assertions in those same tests on my system... so they crashed before getting to the new failure. v2: Use is_gl_identifier. Suggested by Tim. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* glsl: Assert that inputs have a location assignedIan Romanick2016-05-181-0/+2
| | | | | | | This catches a problem previously undetected until deep in the backend. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Fix trivial typos in commentsIan Romanick2016-05-182-8/+8
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Fix some formatting to match current coding conventionsIan Romanick2016-05-181-8/+6
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Silence unused parameter warningIan Romanick2016-05-181-5/+3
| | | | | | | | | | | The use of the parameter was removed in d6b92028. glsl/link_varyings.cpp:1390:39: warning: unused parameter ‘separate_shader’ [-Wunused-parameter] bool separate_shader) ^ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Silence unused parameter warningIan Romanick2016-05-181-3/+2
| | | | | | | | | | | | The parameter appears to have been unused since the function was added in commit 12ba6cfb. Remove it. glsl/linker.cpp:2886:60: warning: unused parameter ‘prog’ [-Wunused-parameter] match_explicit_outputs_to_inputs(struct gl_shader_program *prog, ^ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: make reserved_varying_slot() staticTimothy Arceri2016-05-171-1/+1
| | | | Reviewed-by: Dave Airlie <[email protected]>
* glsl: include per-patch varyings when generating reserved slot bitfieldTimothy Arceri2016-05-171-3/+6
| | | | Reviewed-by: Dave Airlie <[email protected]>
* glsl: don't incorrectly eliminate patches with explicit locationsTimothy Arceri2016-05-171-1/+2
| | | | | | | These varying have a separate location domain from per-vertex varyings and need to be handled separately. Reviewed-by: Dave Airlie <[email protected]>
* glsl: remove remainings tabs in link_varyings.cppTimothy Arceri2016-05-171-2/+2
| | | | Reviewed-by: Dave Airlie <[email protected]>
* glsl: fix location and component packing validation on patchesTimothy Arceri2016-05-171-1/+2
| | | | | | | These varyings have a separate location domain from per-vertex varyings and need to be handled separately. Reviewed-by: Dave Airlie <[email protected]>
* glsl/linker: Include the interface name for input and output blocksIan Romanick2016-05-161-1/+16
| | | | | | | | | On my oes_shader_io_blocks branch, this fixes 71 dEQP-GLES31.functional.program_interface_query.* tests. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: [email protected]
* glsl/linker: Use canonical format for ARB_program_interface_query spec quotesIan Romanick2016-05-161-49/+51
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't do constant propagation in opt_constant_folding.Kenneth Graunke2016-05-152-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | opt_constant_folding is supposed to fold trees of constants into a single constant. Surprisingly, it was also propagating constant values from variables into expression trees - even when the result couldn't be folded together. This is opt_constant_propagation's job. The ir_dereference_variable::constant_expression_value() method returns a clone of var->constant_value. So we would replace the dereference with a constant, propagating it into the tree. Skip over ir_dereference_variable to avoid this surprising behavior. However, add code to explicitly continue doing it in the constant propagation pass, as it's useful to do so. shader-db statistics on Broadwell: total instructions in shared programs: 8905349 -> 8905126 (-0.00%) instructions in affected programs: 30100 -> 29877 (-0.74%) helped: 93 HURT: 20 total cycles in shared programs: 71017030 -> 71015944 (-0.00%) cycles in affected programs: 132456 -> 131370 (-0.82%) helped: 54 HURT: 45 The only hurt programs are by a single instruction, while the helped ones are helped by 1-4 instructions. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Avoid excess tree walking when folding ir_dereference_arrays.Kenneth Graunke2016-05-151-0/+6
| | | | | | | | | | | | | | | | | | | If an ir_dereference_array has non-constant components, there's no point in trying to evaluate its value (which involves walking down the tree and possibly allocating memory for portions of the subtree which are constant). This also removes convoluted tree walking in opt_constant_folding(), which tries to fold constants while walking up the tree. No need to walk down, then up, then down again. We did this for swizzles and expressions already, but I was lazy back in the day and didn't do this for ir_dereference_array. No change in shader-db. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Consolidate duplicate copies of constant folding.Kenneth Graunke2016-05-153-32/+19
| | | | | | | | | | We could probably clean this up more (maybe make it a method), but at least there's only one copy of this code now, and that's a start. No change in shader-db. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove bonus tree walking in opt_constant_folding().Kenneth Graunke2016-05-151-2/+0
| | | | | | | | | | | | | | It looks like this was missed when converting opt_constant_folding() from a hierarchical visitor to an rvalue visitor in 6606fde3. ir_rvalue_visitor already processes values on the way back up the tree, so we will have already visited every child node. There's no point in doing it again. No change in shader-db. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Make opt_constant_variable() bail in useless cases.Kenneth Graunke2016-05-151-0/+7
| | | | | | | | | | | | | | | The pass ultimately skips over any entries with assignment_count != 1, so there's no need to do further work once we've determined that there are multiple assignments. The constant value could be a large array (i.e. uvec4[327]), at which point skipping the constant_expression_value() call (and the clone() call within) can save us piles of memory. No change in shader-db. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Drop bad ASSERT_TRUE in gl_CullDistance link_varyings test.Kenneth Graunke2016-05-151-6/+6
| | | | | | | | | | | | I don't know what the intention was here, but this function returns void. We can't assert anything about its return value. Fixes "make check" failures. v2: Also fix prototype for the function (caught by Jordan). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* Revert "glsl: Extend lowering pass for gl_ClipDistance to support other ↵Dave Airlie2016-05-143-160/+95
| | | | | | | | arrays (v4)" This reverts commit ad355652c20b245f5f2faa8622e71461e3121a7f. This broke a bunch of clip tests.
* glsl: make sure that textureProj(bias) variants are only exposed in fsIlia Mirkin2016-05-131-37/+37
| | | | | | | | | Many were already marked as fs_only, but not all. This fixes the remaining ir_txb entries. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: be more strict when validating shader inputsIlia Mirkin2016-05-131-8/+18
| | | | | | | | | | | | | | | | | | interpolateAt* can only take input variables or an element of an input variable array. No structs. Further, GLSL 4.40 relaxes the requirement to allow swizzles, so enable that as well. This fixes the following dEQP tests: dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.negative.interpolate_struct_member dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_centroid.negative.interpolate_struct_member dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.negative.interpolate_struct_member Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: make sure that interpolateAt arguments are variablesIlia Mirkin2016-05-131-1/+1
| | | | | | | | | | | | | | | In the case of a constant, it might have been propagated through and variable_referenced() returns NULL. Error out in that case. Fixes 3 dEQP tests: dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.negative.interpolate_constant dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_centroid.negative.interpolate_constant dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.negative.interpolate_constant Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Add arb_cull_distance support (v3)Tobias Klausmann2016-05-1410-39/+177
| | | | | | | | | v2: make too large array a compile error v3: squash mesa/prog patch to avoid static compiler errors in bisect Signed-off-by: Tobias Klausmann <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Extend lowering pass for gl_ClipDistance to support other arrays (v4)Tobias Klausmann2016-05-143-95/+160
| | | | | | | | | | | | | | | | | | | This will come in handy when we want to lower gl_CullDistance into gl_CullDistanceMESA. [airlied: drop separate APIs for clip/cull - just use single API to call both passes.] v3: reexamine my sanity, this was pretty broken, the new code creates one copy of gl_ClipDistanceMESA, as the clip distance varying and lowers everything into that in two passes, one for clips one for culls. v4: rework using the passes in clip/cull sizes, instead of the array sizes. Signed-off-by: Tobias Klausmann <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: rename lower_clip_distance to lower_distance.Dave Airlie2016-05-141-54/+54
| | | | | | | | | | This just renames the file in anticipation of adding cull lowering, and renames the internals. Signed-off-by: Tobias Klausmann <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* mesa/main: Add support for GL_ARB_cull_distance (v2)Tobias Klausmann2016-05-143-3/+3
| | | | | | | | | | | | airlied: v2: rename LowerClipDistance to LowerCombinedClipCullDistnace. I don't think we want any other behaviour with any current hw. Signed-off-by: Tobias Klausmann <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: fixed uninitialized pointerJakob Sinclair2016-05-121-0/+5
| | | | | | | | | | | | | Class "ir_constant" had a bunch of constructors where the pointer member "array_elements" had not been initialized. This could have lead to unsafe code if something had tried to write anything to it. This patch fixes this issue by initializing the pointer to NULL in all the constructors. This issue was discovered by Coverity. CID: 401603, 401604, 401605, 401610 Signed-off-by: Jakob Sinclair <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: export accessor for builtin-uniform descriptorsRob Clark2016-05-112-9/+15
| | | | | | | We'll need this for a nir pass to lower builtin-uniform access. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: use var with initializer on global var validationJuan A. Suarez Romero2016-05-113-22/+20
| | | | | | | | | | | | | | | | | | | | | Currently, when cross validating global variables, all global variables seen in the shaders that are part of a program are saved in a table. When checking a variable this already exist in the table, we check both are initialized to the same value. If the already saved variable does not have an initializer, we copy it from the new variable. Unfortunately this is wrong, as we are modifying something it is constant. Also, if this modified variable is used in another program, it will keep the initializer, when it should have none. Instead of copying the initializer, this commit replaces the old variable with the new one. So if we see again the same variable with an initializer, we can compare if both are the same or not. v2: convert tabs in whitespaces (Kenenth Graunke) Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: check geometry output vertices limits.Dave Airlie2016-05-101-0/+8
| | | | | | | | This fixes: GL45-CTS.geometry_shader.limits.max_output_vertices Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Apply memory qualifiers to vars inside named block interfacesEduardo Lima Mitev2016-05-101-7/+15
| | | | | | This is missing and memory qualifiers are currently being ignored for SSBOs. Reviewed-by: Ian Romanick <[email protected]>