summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_builder.h
Commit message (Collapse)AuthorAgeFilesLines
* glsl: rename min(), max() functions to fix MSVC buildBrian Paul2014-01-061-2/+2
| | | | | | | | Evidently, there's some other definition of "min" and "max" that causes MSVC to choke on these function names. Renaming to min2() and max2() fixes things. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add min() and max() functions to builder.cppMaxence Le Doré2014-01-061-0/+3
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Implement [iu]mulExtended() built-ins for ARB_gpu_shader5.Matt Turner2013-10-071-0/+1
| | | | | | | | | | These built-ins have two "out" parameters, which makes implementing them efficiently with our current compiler infrastructure difficult. Instead, implement them in terms of the existing ir_binop_mul IR (to return the low 32-bits) and a new ir_binop_mul64 which returns the high 32-bits. v2: Rename mul64 -> imul_high as suggested by Ken. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add ir_binop_carry and ir_binop_borrow.Matt Turner2013-10-071-0/+2
| | | | | | | | | Calculates the carry out of the addition of two values and the borrow from subtraction respectively. Will be used in uaddCarry() and usubBorrow() built-in implementations. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add conditional-select IR.Matt Turner2013-09-091-0/+1
| | | | | | | | | | | It's a ?: that operates per-component on vectors. Will be used in upcoming lowering pass for ldexp and the implementation of frexp. csel(selector, a, b): per-component result = selector ? a : b Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add optional parameters to the ir_factory constructor.Kenneth Graunke2013-09-091-3/+3
| | | | | | | | | | | | | | Each ir_factory needs an instruction list and memory context in order to be useful. Rather than creating an object and manually assigning these, we can just use optional parameters in the constructor. This makes it possible to create a ready-to-use factory in one line: ir_factory body(&sig->body, mem_ctx); Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add IR builder shortcuts for a bunch of random opcodes.Kenneth Graunke2013-09-091-0/+14
| | | | | | | | | | | | | | | Adding new convenience emitters makes it easier to generate IR involving these opcodes. bitfield_insert is particularly useful, since there is no expr() for quadops. v2: Add fma() and rename lrp() operands to x/y/a to match the GLSL specification (suggested by Matt Turner). Fix whitespace issues. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Expose IR builder support for arbitrary swizzling.Kenneth Graunke2013-09-091-0/+1
| | | | | | | | | | | | | | | | | IR builder already offers a lot of swizzling functions, such as swizzle_xxxx, swizzle_z, or swizzle_for_size. The swizzle_xxxx style is convenient if you statically know which components you want. swizzle_for_size is great if you want to select the first few components. However, if you want to select components based on, say, a loop counter, none of those are sufficient. IR builder actually already had support for arbitrary swizzling, but didn't expose it. This patch exposes that API. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add a new ir_builder::dotlike() function.Kenneth Graunke2013-09-091-0/+1
| | | | | | | | | | | | dotlike() uses ir_binop_mul for scalars, and ir_binop_dot for vectors. When generating built-in functions, we often want to use regular multiply for scalar signatures, and dot() for vector signatures. ir_binop_dot only works on vectors, so we have to switch opcodes, even if the code is otherwise identical. dotlike() makes this easy. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add IR builder support for generating return statements.Kenneth Graunke2013-09-091-0/+2
| | | | | | | | | We use "ret" as the function name since "return" is a C++ keyword, and "ir_return" is already a class name. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add IR builder support for conditional assignments.Kenneth Graunke2013-09-091-0/+2
| | | | | | | | | | | | | This adds two new signatures: assign(lhs, rhs, condition, writemask); assign(lhs, rhs, condition); All the other existing APIs still exist. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add IR builder support for triops.Kenneth Graunke2013-09-091-0/+1
| | | | | | | | | Now that we have the ir_expression constructor that does type inference, this is trivial to do. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add i2b() and b2i() to ir_builder.Matt Turner2013-08-141-0/+2
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add nequal() to ir_builder.Matt Turner2013-08-141-0/+1
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add abs() to ir_builder.Matt Turner2013-08-141-0/+1
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add bitcast_i2f() to ir_builder.Matt Turner2013-08-141-0/+4
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl/ir_builder: Add helpers for making if-statementsChad Versace2013-01-241-0/+6
| | | | | | | | | | | Add two overloaded variants of ir_if *if_tree() The new functions allow one to chain together if-trees within a single C++ expression that resembles a real if-statement. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/ir_builder: Add `enum writemask`Chad Versace2013-01-241-0/+9
| | | | | | | | Using this enum improves the readibility of calls to assign(), whose third argument is a writemask. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/ir_factory: Add helper method for making an ir_constantChad Versace2013-01-241-0/+24
| | | | | | | | Add method ir_factory::constant. This little method constructs an ir_constant using the factory's mem_ctx. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/ir_builder: Add more helpers for constructing expressionsChad Versace2013-01-241-0/+26
| | | | | | | | | | | | | | | | | Add the following functions, each of which construct the similarly named ir expression: div, round_even, clamp equal, less, greater, lequal, gequal logic_not, logic_and, logic_or bit_not, bit_or, bit_and, lshift, rshift f2i, i2f, f2u, u2f, i2u, u2i Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/ir_factory: Initialize members to NULL in constructorChad Versace2013-01-241-0/+7
| | | | | | | This eliminates unexpected behavior due to unitialized values. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: change int->unsigned to silence MSVC warningsBrian Paul2012-11-061-1/+1
| | | | Reviewed-by: Jose Fonseca <[email protected]>
* glsl/ir_builder: Add a new swizzle_for_size() function.Kenneth Graunke2012-07-121-0/+5
| | | | | | | | This swizzles away unwanted components, while preserving the order of the ones that remain. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/ir_builder: Add a generic constructor for unary expressions.Kenneth Graunke2012-07-121-0/+1
| | | | | | | | | I needed to compute logs and square roots in a patch I was working on, and wanted to use the convenient interface. We already have a similar constructor for binops; adding one for unops seems reasonable. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Add a helper for generating temporary variables in ir_builder.Eric Anholt2012-04-131-0/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a helper for ir_builder to make dereferences for assignments.Eric Anholt2012-04-131-0/+24
| | | | | | v2: Fix writemask setup for non-vec4 assignments. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make a little tracking class for emitting IR lists.Eric Anholt2012-04-131-0/+8
| | | | | | | This lets us significantly shorten p->instructions->push_tail(ir), and will be used in a few more places. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add common swizzles to ir_builder.Eric Anholt2012-04-131-0/+12
| | | | | | | | | | Now we can fold a bunch of our expression setup in ff_fragment_shader into single-line, parseable commits. v2: Make it actually work. I wasn't setting num_components in the mask structure, and not setting up a mask structure is way easier. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Let ir_builder expressions take un-dereferenced variables.Eric Anholt2012-04-131-6/+31
| | | | | | | | | | | Having to explicitly dereference is irritating and bloats the code, when the compiler can detect and do the right thing. v2: Use a little shim class to produce the automatic dereference generation at compile time as opposed to runtime, while also allowing compile-time type checking. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Create an ir_builder helper for hand-generating IR.Eric Anholt2012-04-131-0/+35
The C++ constructors with placement new, while functional, are extremely verbose, leading to generation of simple GLSL IR expressions like (a * b + c * d) expanding to many lines of code and using lots of temporary variables. By creating a new ir_builder.h that puts simple generators in our namespace and taking advantage of ralloc_parent(), we can generate much more compact code, at a minor runtime cost. v2: Replace ir_instruction usage with just ir_rvalue. v3: Drop remaining missed as_rvalue() in v2. Reviewed-by: Kenneth Graunke <[email protected]>