summaryrefslogtreecommitdiffstats
path: root/src/glsl/opt_dead_code.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: correctly detect inactive UBO arraysTimothy Arceri2015-09-241-5/+2
| | | | | | | | | Previously the code was trying to get the packing type from the array not the interface. Cc: Ian Romanick <[email protected]> Cc: Antia Puentes <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: don't eliminate subroutine types.Dave Airlie2015-07-231-0/+3
| | | | | | | | This stops dead code from removing subroutines types, we need these for the queries to work properly. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Do not kill dead assignments to buffer variables or SSBO declarations.Iago Toral Quiroga2015-07-141-3/+6
| | | | | | | | | | | | | | | If we kill dead assignments we lose the buffer writes. Also, we never kill UBO declarations even if they are never referenced by the shader, they are always considered active. Although the spec does not seem say this specifically for SSBOs, it is probably implied since SSBOs are pretty much the same as UBOs, only that you can write to them. v2: - Fix the comment (Jordan) Reviewed-by: Jordan Justen <[email protected]>
* mesa: rename is_in_uniform_block to is_in_buffer_blockIago Toral Quiroga2015-07-141-1/+1
| | | | | | | Since this now checks if a variable is inside a uniform or a shader storage block. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Do not eliminate 'shared' or 'std140' blocks or block membersIan Romanick2014-08-041-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 32f32292 (glsl: Allow elimination of uniform block members) enabled elimination of unused uniform block members to fix a gles3 conformance test failure. This went too far the other way. Section 2.11.6 (Uniform Variables) of the OpenGL ES 3.0.3 spec says: "All members of a named uniform block declared with a shared or std140 layout qualifier are considered active, even if they are not referenced in any shader in the program. The uniform block itself is also considered active, even if no member of the block is referenced." Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.single_nested_struct.per_block_buffer_shared ES3-CTS.shaders.uniform_block.single_nested_struct.per_block_buffer_std140 ES3-CTS.shaders.uniform_block.single_nested_struct_array.per_block_buffer_shared ES3-CTS.shaders.uniform_block.single_nested_struct_array.per_block_buffer_std140 ES3-CTS.shaders.uniform_block.random.scalar_types.2 ES3-CTS.shaders.uniform_block.random.scalar_types.9 ES3-CTS.shaders.uniform_block.random.vector_types.1 ES3-CTS.shaders.uniform_block.random.vector_types.3 ES3-CTS.shaders.uniform_block.random.vector_types.7 ES3-CTS.shaders.uniform_block.random.vector_types.9 ES3-CTS.shaders.uniform_block.random.basic_types.5 ES3-CTS.shaders.uniform_block.random.basic_types.6 ES3-CTS.shaders.uniform_block.random.basic_arrays.0 ES3-CTS.shaders.uniform_block.random.basic_arrays.2 ES3-CTS.shaders.uniform_block.random.basic_arrays.5 ES3-CTS.shaders.uniform_block.random.basic_arrays.8 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.0 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.4 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.5 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.6 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.9 ES3-CTS.shaders.uniform_block.random.nested_structs.0 ES3-CTS.shaders.uniform_block.random.nested_structs.1 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.4 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.8 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.7 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.3 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.6 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.18 v2: Whitespace and other minor fixes suggested by Matt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util: Move the open-addressing linear-probing hash_table to src/util.Kenneth Graunke2014-08-041-1/+1
| | | | | | | | | | | | | | | | | This hash table is used in core Mesa, the GLSL compiler, and the i965 driver, which makes it a good candidate for the new src/util module. It's much faster than program/hash_table.[ch] (see commit 6991c2922f5 for data), and José's u_hash_table.c has a comment saying Gallium should probably consider switching to a linear probing hash table at some point. So this seems like the best candidate for a shared data structure. Signed-off-by: Kenneth Graunke <[email protected]> v2 (Jason Ekstrand): Pick up another hash_table use and patch up scons Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: Use typed foreach_in_list instead of foreach_list.Matt Turner2014-07-011-4/+2
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Convert piles of foreach_iter to the newer foreach_list macro.Kenneth Graunke2014-01-131-5/+4
| | | | | | | | | | | | | foreach_iter and exec_list_iterators have been deprecated for some time now; we just hadn't ever bothered to convert code to the newer foreach_list and foreach_list_safe macros. In these cases, we aren't editing the list, so we can use foreach_list rather than foreach_list_safe. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: move variables in to ir_variable::data, part ITapani Pälli2013-12-121-4/+4
| | | | | | | | | | This patch moves following bitfields in to the data structure: used, assigned, how_declared, mode, interpolation, origin_upper_left, pixel_center_integer Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Allow elimination of uniform block membersIan Romanick2013-01-251-6/+1
| | | | | | | | | | | | | | | | | | | glGetActiveUniform is not supposed to report block members that are not active even if they are included in the layout of the block. The block layout is determined from the GLSL_TYPE_INTERFACE that defines the block, so eliminating the ir_variables that correspond to the individual fields is safe. Fixes gles3conform test uniform_buffer_object_getuniformindices_for_for_nonexistent_or_not_active_uniform_names. This also fixes the assertion failures (added in the previous commit) in gles3conform uniform_buffer_object_index_of_not_active_block, uniform_buffer_object_inherit_and_override_layouts, and uniform_buffer_object_repeat_global_scope_layouts. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add ir_variable::is_in_uniform_block predicateIan Romanick2013-01-251-1/+1
| | | | | | | | | The way a variable is tested for this property is about to change, and this makes the code easier to modify. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Eliminate ambiguity between function ins/outs and shader ins/outsPaul Berry2013-01-241-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces the three ir_variable_mode enums: - ir_var_in - ir_var_out - ir_var_inout with the following five: - ir_var_shader_in - ir_var_shader_out - ir_var_function_in - ir_var_function_out - ir_var_function_inout This eliminates a frustrating ambiguity: it used to be impossible to tell whether an ir_var_{in,out} variable was a shader in/out or a function in/out without seeing where the variable was declared in the IR. This complicated some optimization and lowering passes, and would have become a problem for implementing varying structs. In the lisp-style serialization of GLSL IR to strings performed by ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in", "out", and "inout" for function parameters, to avoid introducing code churn to the src/glsl/builtins/ir/ directory. Note: a couple of comments in the code seemed to indicate that we were planning for a possible future in which geometry shaders could have shader-scope inout variables. Our GLSL grammar rejects shader-scope inout variables, and I've been unable to find any evidence in the GLSL standards documents (or extensions) that this will ever be allowed, so I've eliminated these comments. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Use the new hash table for the variable refcount visitor.Eric Anholt2012-12-071-2/+4
| | | | | | | Reviewed-by: Jordan Justen <[email protected]> [[email protected]: open_hash_table => hash_table] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't dead-code eliminiate uniforms declared in uniform blocks.Eric Anholt2012-07-201-1/+7
| | | | | | | This is a requirement for std140 uniform blocks, and optional for packed/shared blocks. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Convert ir_call to be a statement rather than a value.Kenneth Graunke2012-04-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Aside from ir_call, our IR is cleanly split into two classes: - Statements (typeless; used for side effects, control flow) - Values (deeply nestable, pure, typed expression trees) Unfortunately, ir_call confused all this: - For void functions, we placed ir_call directly in the instruction stream, treating it as an untyped statement. Yet, it was a subclass of ir_rvalue, and no other ir_rvalue could be used in this way. - For functions with a return value, ir_call could be placed in arbitrary expression trees. While this fit naturally with the source language, it meant that expressions might not be pure, making it difficult to transform and optimize them. To combat this, we always emitted ir_call directly in the RHS of an ir_assignment, only using a temporary variable in expression trees. Many passes relied on this assumption; the acos and atan built-ins violated it. This patch makes ir_call a statement (ir_instruction) rather than a value (ir_rvalue). Non-void calls now take a ir_dereference of a variable, and store the return value there---effectively a call and assignment rolled into one. They cannot be embedded in expressions. All expression trees are now pure, without exception. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Rename class variable_entry to ir_variable_refcount_entry.Kenneth Graunke2012-01-301-1/+1
| | | | | | | | | | | | | | | | | | | Exporting a publicly visible class with a generic name like "variable_entry" via ir_variable_refcount.h is kind of mean. Many IR transformers would like to define their own "variable_entry" class. If they accidentally include this header, the compiler/linker may get confused and try to instantiate the wrong variable_entry class, leading to bizarre runtime crashes. The hope is that renaming this one will allow .cpp files to safely declare and use their own file-scope "variable_entry" classes. This avoids crashes caused by converting src/glsl to automake. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-and-tested-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Add uniform_locations_assigned parameter to do_dead_code opt passIan Romanick2011-10-251-4/+10
| | | | | | | | | | | | | | | | | Setting this flag prevents declarations of uniforms from being removed from the IR. Since the IR is directly used by several API functions that query uniforms in shaders, uniform declarations cannot be removed after the locations have been set. However, it should still be safe to reorder the declarations (this is not tested). Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41980 Tested-by: Brian Paul <[email protected]> Reviewed-by: Bryan Cain <[email protected]> Cc: Vinson Lee <[email protected]> Cc: José Fonseca <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Yuanhan Liu <[email protected]>
* Use C-style system headers in C++ code to avoid issues with std:: namespaceIan Romanick2011-02-211-2/+0
|
* glsl: Add using statements for standard library functions.Vinson Lee2011-02-031-0/+2
| | | | | | | | | | | | | Standard library functions in C++ are in the std namespace. When using C++-style header files for the standard library, some compilers, such as Sun Studio, provide symbols only for the std namespace and not for the global namespace. This patch adds using statements for standard library functions. Another option could have been to prepend standard library function calls with 'std::'. This patch fixes several compilation errors with Sun Studio.
* glsl: Fix Doxygen tag \file in recently renamed filesChad Versace2010-11-171-1/+1
|
* glsl: Rename various ir_* files to lower_* and opt_*.Kenneth Graunke2010-11-151-0/+142
This helps distinguish between lowering passes, optimization passes, and other compiler code.