summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl ubo/ssbo: Split buffer access to insert_buffer_accessJordan Justen2015-12-091-35/+43
| | | | | | | | | This allows the code in emit_access to be generic enough to also be for lowering shared variables. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl ubo/ssbo: Use enum to track current buffer access typeJordan Justen2015-12-091-5/+21
| | | | | | | | | | v2: * Rename ssbo_get_array_length to ssbo_unsized_array_length_access (Iago) * Use always use this-> when referencing buffer_access_type (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: do not loose always_active_io when packing varyingsTapani Pälli2015-12-101-0/+1
| | | | | | | | | Otherwise packed and inactive varyings get optimized away. This needs to be prevented when using separate shader objects where interface needs to be preserved. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Fix a typo in a commentAndreas Boll2015-12-091-1/+1
| | | | | | | s/suports/supports/ Signed-off-by: Andreas Boll <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* nir: Optimize useless comparisons against true/false.Matt Turner2015-12-081-2/+4
| | | | | | | | | | Reviewed-by: Jason Ekstrand <[email protected]> [v1] Reviewed-by: Eric Anholt <[email protected]> [v1] v2: Move new rule to Boolean simplification section Add a a@bool != true simplification Suggested-by: Neil Roberts <[email protected]>
* glsl: Switch opcode and avail parameters to binop().Matt Turner2015-12-081-17/+18
| | | | | | To make it match unop(). Reviewed-by: Ian Romanick <[email protected]>
* glsl: Relax qualifier ordering restriction in ES 3.1.Matt Turner2015-12-082-10/+15
| | | | | | | | | | | ... and allow the "binding" qualifier in ES 3.1 as well. GLSL ES 3.1 incorporates only a few features from the extension ARB_shading_language_420pack: the relaxed qualifier ordering requirements and the binding qualifier. Cc: "11.1" <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Use has_420pack().Matt Turner2015-12-083-7/+6
| | | | | | | These features would not have been enabled with #version 420 otherwise. Cc: "11.1" <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Allow binding of image variables with 420pack.Matt Turner2015-12-081-1/+3
| | | | | | | | | This interaction was missed in the addition of ARB_image_load_store. Cc: "11.0 11.1" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93266 Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* nir/lower_io: Pass the builder and type_size into get_io_offsetJason Ekstrand2015-12-031-15/+15
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: remove useless null checks and make match_explicit_outputs_to_inputs() ↵Juha-Pekka Heikkila2015-12-031-9/+1
| | | | | | | | | | | static match_explicit_outputs_to_inputs() cannot get null inputs and if it ever did triggering first null check would later in the function cause segfault. Signed-off-by: Juha-Pekka Heikkila <[email protected]> CC: [email protected] Reviewed-by: Timothy Arceri <[email protected]>
* Remove Sun CC specific code.Jose Fonseca2015-12-022-16/+0
| | | | | Reviewed-by: Matt Turner <[email protected]> Acked-by: Alan Coopersmith <[email protected]>
* glsl: Rename safe_reverse -> reverse_safe.Matt Turner2015-12-013-7/+7
| | | | | | To match existing foreach_in_list_reverse_safe. Reviewed-by: Francisco Jerez <[email protected]>
* glsl/lower_ubo_reference: split struct copies into element copiesIago Toral Quiroga2015-12-011-2/+54
| | | | | | | | Improves register pressure, since otherwise we end up emitting loads for all the elements in the RHS and them emitting stores for all elements in the LHS. Reviewed-by: Jordan Justen <[email protected]>
* glsl/lower_ubo_reference: split array copies into element copiesIago Toral Quiroga2015-12-011-0/+67
| | | | | | | | | | | | | | | | | | | | | | | Improves register pressure, since otherwise we end up emitting loads for all the elements in the RHS and them emitting stores for all elements in the LHS. v2: - Mark progress properly. This also fixes some instances where the added nodes with individual element copies where not being lowered, which is expected behavior as explained in the documentation for visit_list_elements. - Only need to do this if the RHS is a buffer-backed variable. - We can also have arrays inside structs. A later patch will make it so we also split struct copies and end up with multiple ir_dereference_record assignments, so make sure that if any of these is an array copy, we also split it. Fixes the following piglit tests: tests/spec/arb_shader_storage_buffer_object/execution/large-field-copy.shader_test tests/spec/arb_shader_storage_buffer_object/linker/copy-large-array.shader_test Reviewed-by: Jordan Justen <[email protected]>
* glsl/dead_builin_varyings: Fix gl_FragData array loweringIago Toral Quiroga2015-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | | The current implementation looks for array dereferences on gl_FragData and immediately proceeds to lower them, however this is not enough because we can have array access on vector variables too, like in this code: out vec4 color; void main() { int i; for (i = 0; i < 4; i++) color[i] = 1.0; } Fix it by making sure that the actual variable being dereferenced is an array. Fixes a crash in: spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-ldexp-dvec4.shader_test Reviewed-by: Tapani Pälli <[email protected]>
* glsl: don't sort varying in separate shader modeGregory Hainaut2015-12-011-6/+32
| | | | | | | | | | | | | | | This fixes an issue where the addition of the FLAT qualifier in varying_matches::record() can break the expected varying order. It also avoids a future issue with the relaxing of interpolation qualifier matching constraints in GLSL 4.50. V2: (by Timothy Arceri) * reworked comment slightly Signed-off-by: Gregory Hainaut <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: don't dead code remove SSO varyings marked as activeGregory Hainaut2015-12-011-0/+14
| | | | | | | | | | | | | | | | | GL_ARB_separate_shader_objects allow matching by name variable or block interface. Input varyings can't be removed because it is will impact the location assignment. This fixes the bug 79783 and likely any application that uses GL_ARB_separate_shader_objects extension. V2 (by Timothy Arceri): * simplify now that builtins are not set as always active Signed-off-by: Gregory Hainaut <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> https://bugs.freedesktop.org/show_bug.cgi?id=79783
* glsl: add always_active_io attribute to ir_variableGregory Hainaut2015-12-013-0/+82
| | | | | | | | | | | | | | | | | | | | | | The value will be set in separate-shader program when an input/output must remains active. e.g. when deadcode removal isn't allowed because it will create interface location/name-matching mismatch. v3: * Rename the attribute * Use ir_variable directly instead of ir_variable_refcount_visitor * Move the foreach IR code in the linker file v4: * Fix variable name in assert v5 (by Timothy Arceri): * Rename functions and reword comments * Don't set always active on builtins Signed-off-by: Gregory Hainaut <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: copy how_declared when lowering interface blocksTimothy Arceri2015-12-011-0/+1
| | | | | Cc: Gregory Hainaut <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: optimise inputs/outputs with explicit locationsTimothy Arceri2015-12-012-14/+74
| | | | | | | | | | | | | | | | | | | This change allows used defined inputs/outputs with explicit locations to be removed if they are detected to not be used between shaders at link time. To enable this we change the is_unmatched_generic_inout field to be flagged when we have a user defined varying. Previously explicit_location was assumed to be set only in builtins however SSO allows the user to set an explicit location. We then add a function to match explicit locations between shaders. V2: call match_explicit_outputs_to_inputs() after is_unmatched_generic_inout has been initialised. Cc: Gregory Hainaut <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* mesa: remove len argument from _mesa_shader_debug()Emil Velikov2015-11-293-3/+3
| | | | | | | | | | There was only a single user which was using strlen(buf). As this function is not user facing (i.e. we don't need to feed back original length via a callback), we can simplify things. Suggested-by: Timothy Arceri <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: remove recursive inclusion in builtin_type_macros.hEmil Velikov2015-11-291-2/+0
| | | | | | | The header is already included by glsl_types.{cpp,h}. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: remove unneeded includeEmil Velikov2015-11-291-1/+0
| | | | | Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: include what we want/needEmil Velikov2015-11-251-1/+1
| | | | | | | | Swap core.h with macros.h, as the latter provides the required MAX2 macro. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: handle case where index is array deref in optimize_split_arraysTapani Pälli2015-11-251-0/+4
| | | | | | | | | Previously pass did not traverse to those array dereferences which were used as indices to arrays. This fixes Synmark2 Gl42CSCloth application issues. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: remove trailing spaces in various filesIago Toral Quiroga2015-11-254-9/+8
| | | | Acked-by: Kenneth Graunke <[email protected]>
* glsl: only call dead code pass when new inputs/outputs demotedTimothy Arceri2015-11-251-10/+14
| | | | | | | This will help avoid eliminating inputs/outputs needed by SSOs. Cc: Gregory Hainaut <[email protected]> Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: move and reused code to find first and last shadersTimothy Arceri2015-11-251-18/+12
| | | | Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* glsl: Pass ast_type_qualifier by const reference.Matt Turner2015-11-243-9/+9
| | | | | | | Coverity noticed that we were passing this by value, and it's 152 bytes. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/lower_tex: Add support for lowering texture swizzleJason Ekstrand2015-11-232-0/+80
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Add a tex_instr_is_query helperJason Ekstrand2015-11-231-0/+25
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Add a ssa_def_rewrite_uses_after helperJason Ekstrand2015-11-232-0/+51
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Use instr/if_rewrite in nir_ssa_def_rewrite_usesJason Ekstrand2015-11-231-12/+4
| | | | | | | nir_ssa_def_rewrite_uses is one of the older helpers in NIR and predated both of those. Now it can be substantially simplified. Reviewed-by: Connor Abbott <[email protected]>
* nir/validate: Validated dests after sourcesJason Ekstrand2015-11-231-9/+9
| | | | | | | | | | | | | Previously, if someone accidentally made an instruction that refers to its own SSA destination, the validator wouldn't catch it. The reason for this is that it validated the destination too early and, by the time it got to the source, the destination SSA value was already added to the set of seen SSA values so it would assume that it came from some previous instruction. By moving destination validation to be after source validation, the SSA value is not in the list of seen values and the validator will catch self-referential instructions. Reviewed-by: Connor Abbott <[email protected]>
* nir/lower_tex: Set the dest_type for txs instructionsJason Ekstrand2015-11-231-0/+1
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/lower_tex: Report progressJason Ekstrand2015-11-232-5/+16
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: s/nir_type_unsigned/nir_type_uintJason Ekstrand2015-11-235-44/+44
| | | | | | | | | | | v2: do the same in tgsi_to_nir (Samuel) v3: added missing cases after rebase (Iago) v4: Add a blank space after '#' in one of the comments (Matt) Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir/builder: only read meaningful channels in nir_swizzle()Connor Abbott2015-11-231-1/+1
| | | | | | | | | | This way the caller doesn't have to initialize all 4 channels when they aren't using them. v2: Fix signed/unsigned comparison warning (Iago) Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: fix max binding validation for uniform blocksTimothy Arceri2015-11-231-2/+2
| | | | | | | | | Regression as of 64710db66461e We can't use the type returned by get_interface_type() as the interface type has arrays removed. Reviewed-by: Emil Velikov <[email protected]>
* nir: Add support for gl_HelperInvocation system value.Matt Turner2015-11-202-0/+5
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: add subroutine index qualifier supportTimothy Arceri2015-11-217-4/+83
| | | | | | | | | | | | | | | | | | | | | | | ARB_explicit_uniform_location allows the index for subroutine functions to be explicitly set in the shader. This patch reduces the restriction on the index qualifier in validate_layout_qualifiers() to allow it to be applied to subroutines and adds the new subroutine qualifier validation to ast_function::hir(). ast_fully_specified_type::has_qualifiers() is updated to allow the index qualifier on subroutine functions when explicit uniform locations is available. A new check is added to ast_type_qualifier::merge_qualifier() to stop multiple function qualifiers from being defied, before this patch this would cause a segfault. Finally a new variable is added to ir_function_signature to store the index. This value is validated and the non explicit values assigned in link_assign_subroutine_types(). Reviewed-by: Tapani Pälli <[email protected]>
* glsl: add support for complie-time constant expressionsTimothy Arceri2015-11-215-164/+195
| | | | | | | | | | | | | | | | | | | This patch replaces the old interger constant qualifiers with either the new ast_layout_expression type if the qualifier requires merging or ast_expression if the qualifier can't have mulitple declarations or if all but the newest qualifier is simply ignored. We also update the process_qualifier_constant() helper to be similar to the one in the ast_layout_expression class, but in this case it will be used to process the ast_expression qualifiers. Global shader layout qualifier validation is moved out of the parser in this change as we now need to evaluate any constant expression before doing the validation. V2: Fix minimum value check for vertices (Emil) Reviewed-by: Emil Velikov <[email protected]>
* glsl: add new type for compile time constantsTimothy Arceri2015-11-212-0/+80
| | | | | | | | | | | | | | | | | | | | | | | In this patch we introduce a new ast type for holding the new compile-time constant expressions. The main reason for this is that we can no longer do merging of layout qualifiers before they have been converted into GLSL IR so we need to store them to be proccessed later. The new type has two helper functions: - process_qualifier_constant() Used to merge and then evaluate qualifier expressions - merge_qualifier() Simply appends a qualifier to a list to be merged later by process_qualifier_constant() In order to avoid cascading error messages the process_qualifier_constant() helpers return a bool Reviewed-by: Emil Velikov <[email protected]>
* glsl: call set_shader_inout_layout() earlierTimothy Arceri2015-11-211-3/+3
| | | | | | | | This will allow us to add error checking to this function in a later patch, if we don't move it the error messages will go missing. Reviewed-by: Emil Velikov <[email protected]>
* glsl: replace binding layout min boundary checkTimothy Arceri2015-11-211-11/+12
| | | | | | | Use new helper that will in a later patch allow for compile time constants. Reviewed-by: Emil Velikov <[email protected]>
* glsl: encapsulate binding validation and settingTimothy Arceri2015-11-211-32/+28
| | | | | | | | | | | | | | | | | | This change moves the binding layout handing code into an apply function to be consistent with other helper functions in the ast code, and to encapsulate the code so that when we introduce compile time constants the code will be much cleaner. One small downside is for unnamed interface blocks we will now be revalidating the binding for each member its applied to. However this seems a small sacrifice in order to have code which is readable. We also remove the incorrect comment in the named interface code about propagating bindings to members which seems to have been copied from the unnamed interface code. Reviewed-by: Emil Velikov <[email protected]>
* glsl: move stream layout max validationTimothy Arceri2015-11-212-16/+19
| | | | | | | | | This validation is moved later so we can validate the max value when compile time constant support is added in a later patch. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* glsl: move stream layout qualifier validationTimothy Arceri2015-11-212-20/+35
| | | | | | | | | | | | | | | | | We are moving this out of the parser in preparation for compile time constant support. The reason a validation function is used rather than an apply function like what is used with bindings is because glsl allows streams to be defined on members of blocks even though they must match the stream thats associated with the current block, this means we need access to the value after validation to do this comparision. V2: Fix typo in comment (Emil) Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* glsl: replace index layout min boundary checkTimothy Arceri2015-11-211-3/+6
| | | | | | | | Use new helper that will in a later patch allow for compile time constants. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Emil Velikov <[email protected]>