summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_algebraic.py
Commit message (Collapse)AuthorAgeFilesLines
* nir/algebraic: Only replace an instruction onceJason Ekstrand2015-01-151-1/+3
| | | | | | | | | Without the break, it was possible that an instruction would match multiple expressions. If this happened, you could end up trying to replace it multiple times and get a segfault. This makes it so that, after a successful replacement, it moves on to the next instruction. Reviewed-by: Connor Abbott <[email protected]>
* nir/metadata: Rename metadata_dirty to metadata_preserveJason Ekstrand2015-01-151-2/+2
| | | | | | | | | 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 <[email protected]>
* 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 <[email protected]>