summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* nir: Add a foreach_ssa_def functionJason Ekstrand2015-01-152-0/+43
| | | | | | | | | | | | There are some functions whose destinations are SSA-only and so aren't a nir_dest. This provides a function that is capable of iterating over the SSA definitions defined by those functions. If you want registers, you should use the old iterator. v2: Kenneth Graunke <kenneth@whitecape.org>: - Fix nir_foreach_ssa_def's return value. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_variables: Use a real dominance DFS for variable renamingJason Ekstrand2015-01-151-4/+5
| | | | | | | | | | | | | | | | | | | | | | Previously, we were just iterating over the program "in order" which kind-of approximates a DFS, but not really. In particular, we got the following case wrong: loop { a = 3; if (foo) { a = 5; } else { break; } use(a); } where use(a) would get 3 instead of 5 because of premature popping of the SSA def stack. Now, since we do an actaul DFS, we should evaluate use(a) immediately after a = 5 and we should be ok. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Remove predicationJason Ekstrand2015-01-159-259/+7
| | | | | | | | We stopped generating predicates in glsl_to_nir some time ago. Right now, it's all dead untested code that I'm not convinced always worked in the first place. If we decide we want them back, we can revert this patch. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make bcsel a fully vector operationJason Ekstrand2015-01-154-3/+7
| | | | | | | | Previously, the condition was a scalar that applied to all components simultaneously. As of this commit, the condition is a vector and each component is switched seperately. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Call nir_metadata_preserve more placesJason Ekstrand2015-01-158-2/+27
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/metadata: Rename metadata_dirty to metadata_preserveJason Ekstrand2015-01-158-16/+18
| | | | | | | | | nir_metadata_dirty was a terrible name because the parameter it takes is the metadata to be preserved. This is really confusing because it looks like it's doing the opposite of what it is actually doing. Now it's named sensibly. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Rework the way samplers are loweredJason Ekstrand2015-01-151-75/+78
| | | | | | | | v2 Jason Ekstrand <jason.ekstrand@intel.com>: - Use the nir_tex_src_sampler_offset source type instead of the sampler_indirect thing that I cooked up before. Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* nir/tex_instr_create: Initialize all 4 sourcesJason Ekstrand2015-01-151-1/+1
| | | | | | | This helps a lot with things like lowering passes that may need to add sources. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/tex_instr: Rename the indirect source type and add an array sizeJason Ekstrand2015-01-153-3/+16
| | | | | | | | | In particular, we rename nir_tex_src_sampler_index to _sampler_offset and add a sampler_array_size field to nir_tex_instr. This way we can pass the size of sampler arrays through to backends even after removing the variable information and, with it, the type. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Use a source for uniform buffer indices instead of an indexJason Ekstrand2015-01-152-18/+17
| | | | | | | | | | In GLSL-to-NIR we were just setting the base index to 0 whenever there was an indirect so having it expressed as a sum makes no sense. Also, while a base offset may make sense for the memory location (first element in the array, etc.) it makes less sense for the actual uniform buffer index. This may change later, but it seems to make more sense for now. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Constant fold array indirectsJason Ekstrand2015-01-151-8/+76
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make texture instruction names more consistentJason Ekstrand2015-01-1510-23/+23
| | | | | | | | This commit renames nir_instr_as_texture to nir_instr_as_tex and renames nir_instr_type_texture to nir_instr_type_tex to be consistent with nir_tex_instr. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Remove the ffma peepholeJason Ekstrand2015-01-152-190/+0
| | | | | | | This is no longer needed because it's now part of the algebraic optimization pass Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a basic constant folding passJason Ekstrand2015-01-153-0/+281
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add an algebraic optimization passJason Ekstrand2015-01-154-2/+89
| | | | | | | | | This pass uses the previously built algebraic transformations framework and should act as an example for anyone else wanting to make an algebraic transformation pass for NIR. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add infastructure for generating algebraic transformation passesJason Ekstrand2015-01-151-0/+255
| | | | | | | | | | | | | | | | | | | | | | | This commit builds on the nir_search.h infastructure by adding a bit of python code that makes it stupid easy to write an algebraic transformation pass. The nir_algebraic.py file contains four python classes that correspond directly to the datastructures in nir_search.c and allow you to easily generate the C code to represent them. Given a list of search-and-replace operations, it can then generate a function that applies those transformations to a shader. The transformations can be specified manually, or they can be specified using nested tuples. The nested tuples make a neat little language for specifying expression trees and search-and-replace operations in a very readable and easy-to-edit fasion. The generated code is also fairly efficient. Insteady of blindly calling nir_replace_instr with every single transformation and on every single instruction, it uses a switch statement on the instruction opcode to do a first-order culling and only calls nir_replace_instr if the opcode is known to match the first opcode in the search expression. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add an expression matching frameworkJason Ekstrand2015-01-153-0/+446
| | | | | | | | | | | | | | | This framework provides a simple way to do simple search-and-replace operations on NIR code. The nir_search.h header provides four simple data structures for representing expressions: nir_value and four subtypes: nir_variable, nir_constant, and nir_expression. An expression tree can then be represented by nesting these data structures as needed. The nir_replace_instr function takes an instruction, an expression, and a value; if the instruction matches the expression, it is replaced with a new chain of instructions to generate the given replacement value. The framework keeps track of swizzles on sources and automatically generates the currect swizzles for the replacement value. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/glsl: Emit abs, neg, and sat operations instead of source modifiersJason Ekstrand2015-01-151-6/+3
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make the type casting operations static inline functionsJason Ekstrand2015-01-151-32/+32
| | | | | | | | | | | | | Previously, the casting operations were macros. While this is usually fine, the casting macro used the input parameter twice leading to strange behavior when you passed the result of another function into it. Since we know the source and destination types explicitly, we don't loose anything by making it a function. Also, this gives us a nice little macro for creating cast function that will hopefully prevent mistyping. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a lowering pass for adding source modifiers where possibleJason Ekstrand2015-01-153-0/+183
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add neg, abs, and sat opcodesJason Ekstrand2015-01-151-0/+5
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a helper for getting a constant value from an SSA sourceJason Ekstrand2015-01-152-0/+20
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/glsl: Add support for gpu_shader5 interpolation instrinsicsJason Ekstrand2015-01-151-1/+79
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add gpu_shader5 interpolation intrinsicsJason Ekstrand2015-01-152-27/+21
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/validate: Validate intrinsic source/destination sizesJason Ekstrand2015-01-151-0/+26
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Vectorize intrinsicsJason Ekstrand2015-01-158-267/+107
| | | | | | | | | | We used to have the number of components built into the intrinsic. This meant that all of our load/store intrinsics had vec1, vec2, vec3, and vec4 variants. This lead to piles of switch statements to generate the correct intrinsic names, and introspection to figure out the number of components. We can make things much nicer by allowing "vectorized" intrinsics. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Remove the old variable lowering codeJason Ekstrand2015-01-153-1245/+0
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/validate: Ensure that outputs are write-only and inputs are read-onlyJason Ekstrand2015-01-151-0/+23
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/glsl: Generate SSA NIRJason Ekstrand2015-01-151-129/+117
| | | | | | | | | With this commit, the GLSL IR -> NIR pass generates NIR in more-or-less SSA form. It's SSA in the sense that it doesn't have any registers, but it isn't really useful SSA because it still has a pile of load/store intrinsics that we will need to get rid of. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a pass to lower global variables to local variablesJason Ekstrand2015-01-153-0/+109
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a pass for lowering input/output loads/storesJason Ekstrand2015-01-153-0/+394
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a pass to lower local variables to registersJason Ekstrand2015-01-153-0/+316
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a pass to lower local variable accesses to SSA valuesJason Ekstrand2015-01-153-0/+1069
| | | | | | | | | This pass analizes all of the load/store operations and, when a variable is never aliased (potentially used by an indirect operation), it is lowered directly to an SSA value. This pass translates to SSA directly and does not require any fixup by the original to-SSA pass. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a copy splitting passJason Ekstrand2015-01-153-0/+288
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Automatically update SSA if usesJason Ekstrand2015-01-151-5/+4
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/glsl: Don't allocate a state_slots array for 0 state slotsJason Ekstrand2015-01-151-6/+12
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Validate that the sources of a phi have the same size as the destinationJason Ekstrand2015-01-151-0/+13
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/copy_propagate: Don't cause size mismatches on phi node sourcesJason Ekstrand2015-01-151-0/+12
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Don't require a function in ssa_def_initJason Ekstrand2015-01-156-24/+41
| | | | | | | | Instead, we give SSA definitions a temporary index of 0xFFFFFFFF if the instruction does not have a block and a proper index when it actually gets added to the list. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Use an integer index for specifying structure fieldsJason Ekstrand2015-01-159-83/+75
| | | | | | | Previously, we used a string name. It was nice for translating out of GLSL IR (which also does that) but cumbersome the rest of the time. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a concept of a wildcard array dereferenceJason Ekstrand2015-01-152-0/+12
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make array deref direct vs. indirect an enumJason Ekstrand2015-01-158-15/+25
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Clean up nir_deref helper functionsJason Ekstrand2015-01-151-1/+4
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_samplers: Use the nir_instr_rewrite_src functionJason Ekstrand2015-01-151-1/+10
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a helper for rewriting an instruction sourceJason Ekstrand2015-01-152-0/+62
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/from_ssa: Don't lower constant SSA values to registersJason Ekstrand2015-01-151-8/+32
| | | | | | | | | | | Backends want to be able to do special things with constant values such as put them into immediates or make decisions based on whether or not a value is constant. Before, constants always got lowered to a load_const into a register and then a register use. Now we leave constants as SSA values so backends can special-case them if they want. Since handling constant SSA values is trivial, this shouldn't be a problem for backends. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a basic CSE passJason Ekstrand2015-01-153-0/+272
| | | | | | | This pass is still fairly basic. It only handles ALU operations, constant loads, and phi nodes. No texture ops or intrinsics yet. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a fused multiply-add peepholeJason Ekstrand2015-01-154-0/+194
|
* nir: Validate that the SSA def and register indices are uniqueJason Ekstrand2015-01-151-0/+41
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a peephole select optimizationJason Ekstrand2015-01-153-0/+217
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>