summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Remove inverse() from GLSL 1.20 and 1.30.Kenneth Graunke2015-12-161-3/+9
| | | | | | | | | | I apparently regressed this when rewriting the built-ins using ir_builder, in 76d2f73643f. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93387 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir/lower_system_values: Refactor and use the builder.Jason Ekstrand2015-12-151-29/+31
| | | | | | | | | Now that we have a helper in the builder for system values and a helper in core NIR to get the intrinsic opcode, there's really no point in having things split out into a helper function. This commit "modernizes" this pass to use helpers better and look more like newer passes. Reviewed-by: Eric Anholt <[email protected]>
* nir/builder: Add a load_system_value helperJason Ekstrand2015-12-152-10/+15
| | | | | | While we're at it, go ahead and make nir_lower_clip use it. Reviewed-by: Eric Anholt <[email protected]>
* nir/lower_system_values: Stop supporting non-SSAJason Ekstrand2015-12-151-8/+6
| | | | | | The one user of this (i965) only ever calls it while in SSA form. Reviewed-by: Eric Anholt <[email protected]>
* glsl: add support for explicit locations inside interface blocksTimothy Arceri2015-12-154-9/+105
| | | | | | | This change also adds explicit location support for structs and interfaces which is currently missing in Mesa but is allowed with SSO and GLSL 1.50+. Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: simplify interface matchingTimothy Arceri2015-12-151-108/+46
| | | | | | | | | | | | This makes the code easier to follow, should be more efficient and will makes it easier to add matching via explicit locations in the following patch. This patch also replaces the hash table with the newer resizable hash table this should be more suitable as the table is likely to only contain a small number of entries. Reviewed-by: Edward O'Callaghan <[email protected]>
* nir: Fix number of indices on shared variable store intrinsics.Kenneth Graunke2015-12-141-1/+1
| | | | | | | | | | | | | Shared variables and input reworks landed around the same time. Presumably, this was some sort of mistake in rebase conflict resolution. This really only affects the num_indices field in nir_intrinsic_infos, which is rarely used. However, it's used by the printer. Found by inspection. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: assign varying locations to tess shaders when doing SSOIlia Mirkin2015-12-131-4/+4
| | | | | | | | | | | GRID Autosport uses SSO shaders. When a tessellation evaluation shader is passed through this, it triggers assertion failures down the line with unassigned varying locations. Make sure to do this when the first shader in the pipeline is not a vertex shader. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: "11.0 11.1" <[email protected]>
* nir: silence uninitialized warningTimothy Arceri2015-12-111-1/+1
| | | | Reviewed-by: Rob Clark <[email protected]>
* nir: Get rid of *_indirect variants of input/output load/store intrinsicsJason Ekstrand2015-12-108-185/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is some special-casing needed in a competent back-end. However, they can do their special-casing easily enough based on whether or not the offset is a constant. In the mean time, having the *_indirect variants adds special cases a number of places where they don't need to be and, in general, only complicates things. To complicate matters, NIR had no way to convdert an indirect load/store to a direct one in the case that the indirect was a constant so we would still not really get what the back-ends wanted. The best solution seems to be to get rid of the *_indirect variants entirely. This commit is a bunch of different changes squashed together: - nir: Get rid of *_indirect variants of input/output load/store intrinsics - nir/glsl: Stop handling UBO/SSBO load/stores differently depending on indirect - nir/lower_io: Get rid of load/store_foo_indirect - i965/fs: Get rid of load/store_foo_indirect - i965/vec4: Get rid of load/store_foo_indirect - tgsi_to_nir: Get rid of load/store_foo_indirect - ir3/nir: Use the new unified io intrinsics - vc4: Do all uniform loads with byte offsets - vc4/nir: Use the new unified io intrinsics - vc4: Fix load_user_clip_plane crash - vc4: add missing src for store outputs - vc4: Fix state uniforms - nir/lower_clip: Update to the new load/store intrinsics - nir/lower_two_sided_color: Update to the new load intrinsic NIR and i965 changes are Reviewed-by: Kenneth Graunke <[email protected]> NIR indirect declarations and vc4 changes are Reviewed-by: Eric Anholt <[email protected]> ir3 changes are Reviewed-by: Rob Clark <[email protected]> NIR changes are Acked-by: Rob Clark <[email protected]>
* nir: Add nir intrinsics for shared variable atomic operationsJordan Justen2015-12-092-0/+94
| | | | | | | | | v3: * Update min/max based on latest SSBO code (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Disable several optimizations on shared variablesJordan Justen2015-12-093-3/+6
| | | | | | | | | | Shared variables can be accessed by other threads within the same local workgroup. This prevents us from performing certain optimizations with shared variables. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Buffer atomics are supported for compute shadersJordan Justen2015-12-091-32/+38
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Translate atomic intrinsic functions on shared variablesJordan Justen2015-12-091-0/+148
| | | | | | | | | | | | | | | | | When an intrinsic atomic operation is used on a shared variable, we translate it to a new 'shared variable' specific intrinsic function call. For example, a call to __intrinsic_atomic_add when used on a shared variable will be translated to a call to __intrinsic_atomic_add_shared. v3: * Fix stale comments copied from SSBOs (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Check for SSBO variable in check_for_ssbo_storeJordan Justen2015-12-091-1/+1
| | | | | | | | | The compiler probably already blocks this earlier on, but we should be checking for an SSBO here. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Check for SSBO variable in SSBO atomic loweringJordan Justen2015-12-091-0/+14
| | | | | | | | | | | | | When an atomic function is called, we need to check to see if it is for an SSBO variable before lowering it to the SSBO specific intrinsic function. v2: * is_in_buffer_block => is_in_shader_storage_block (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Replace atomic_ssbo and ssbo_atomic with atomicJordan Justen2015-12-093-132/+132
| | | | | | | | | | | | | | | | | The atomic functions can also be used with shared variables in compute shaders. When lowering the intrinsic in lower_ubo_reference, we still create an SSBO specific intrinsic since SSBO accesses can be indirectly addressed, whereas all compute shader shared variable live in a single shared variable area. v2: * Also remove the _internal suffix from ssbo atomic intrinsic names (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Allow atomic functions to be used with shared variablesJordan Justen2015-12-091-8/+10
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Translate glsl shared var store intrinsic to nir intrinsicJordan Justen2015-12-092-1/+35
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Translate glsl shared var load intrinsic to nir intrinsicJordan Justen2015-12-092-0/+30
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add lowering pass for shared variable referencesJordan Justen2015-12-094-0/+354
| | | | | | | | | | | | | | | | | In this lowering pass, shared variables are decomposed into intrinsic calls. v2: * Send mem_ctx as a parameter (Iago) v3: * Shared variables don't have an associated interface block (Iago) * Always use 430 packing (Iago) * Comment / whitespace cleanup (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Don't assert on shared variable matrices with 'inherited' layoutIago Toral Quiroga2015-12-091-2/+9
| | | | | | | We use column-major for shared variable matrices. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Don't lower_variable_index_to_cond_assign for shared variablesJordan Justen2015-12-091-0/+3
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Remove mem_ctx as member variable in lower_ubo_reference_visitorJordan Justen2015-12-091-32/+36
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl ubo/ssbo: Move common code into lower_buffer_access::setup_buffer_accessJordan Justen2015-12-093-157/+185
| | | | | | | | | | | | | | This code will also be usable by the pass to lower shared variables. Note, that *const_offset is adjusted by setup_buffer_access so it must be initialized before calling setup_buffer_access. v2: * Add comment for lower_buffer_access::setup_buffer_access Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl ubo/ssbo: Move is_dereferenced_thing_row_major into lower_buffer_accessJordan Justen2015-12-093-90/+92
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl ubo/ssbo: Add lower_buffer_access classJordan Justen2015-12-094-183/+286
| | | | | | | | | | | | | | | | | This class has code that will be shared by lower_ubo_reference and lower_shared_reference. (lower_shared_reference will be used to support compute shader shared variables.) v2: * Add lower_buffer_access.h to makefile (Emil) * Remove static is_dereferenced_thing_row_major from lower_buffer_access.cpp. This will become a lower_buffer_access method in the next commit. * Pass mem_ctx as parameter rather than using a member variable (Iago) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* 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]>