aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_constant_expression.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Handle constant expressions involving ir_binop_equal/nequal.Kenneth Graunke2011-11-101-0/+6
| | | | | | | | | | | Constant expressions which called GLSL's equal() and notEqual() built-ins on bvecs would hit an assertion failure; we simply forgot to implement them for booleans. NOTE: This is a candidate for stable release branches. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Fix copy-paste error in constant_expression_value(ir_binop_nequal)Paul Berry2011-10-311-1/+1
| | | | | | | | | | | The implementation of ir_binop_nequal in constant_expression_value() appears to have been copy-and-pasted from the implementation of ir_binop_equal, but with all instances of '==' changed to '!='. This is correct except for one minor flaw: one of those '==' operators was in an assertion checking that the types of the two arguments were equal. That one needs to stay an '=='. Fixes piglit tests {fs,vs}-inline-notequal.
* glsl: Add support for constant expression evaluation on round(), roundEven().Eric Anholt2011-10-231-0/+29
| | | | | | | | | | | | v2: Avoid the C99 rounding functions, because I don't trust get/setting the C99 rounding mode from inside our library not having other side effects. Instead, open-code roundEven() behavior around Mesa's IROUND, which we're already testing for C99 rounding mode safety. Fixes glsl-1.30/compiler/built-in-functions/round* Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for constant expression evaluation on trunc().Eric Anholt2011-09-281-0/+2
| | | | | | | Fixes the glsl-1.30/compiler/built-in-functions/trunc-* tests under 1.30. Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix assertion checking types of constant bitshift expressions.Eric Anholt2011-09-281-1/+3
| | | | | | | | Bitshifts are one of the rare places that GLSL allows mixed base types without an implicit conversion occurring. Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add ir_unop_i2u and ir_unop_u2i operations.Bryan Cain2011-06-291-1/+12
| | | | | | | | | | | | | | | | | These are necessary to handle int/uint constructor conversions. For example, the following code currently results in a type mismatch: int x = 7; uint y = uint(x); In particular, uint(x) still has type int. This commit simply adds the new operations; it does not generate them, nor does it add backend support for them. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Reinstate constant-folding for division by zeroChad Versace2011-02-151-21/+21
| | | | | | | | | | | | | | | Fixes regression: https://bugs.freedesktop.org/show_bug.cgi?id=34160 Commit e7c1f058d18f62aa4871aec623f994d7b68cb8c1 disabled constant-folding when division-by-zero occured. This was a mistake, because the spec does allow division by zero. (From section 5.9 of the GLSL 1.20 spec: Dividing by zero does not cause an exception but does result in an unspecified value.) For floating-point division, the original pre-e7c1f05 behavior is reinstated. For integer division, constant-fold 1/0 to 0.
* Revert "glsl: Fix constant-folding for reciprocal expressions"Chad Versace2011-02-151-10/+6
| | | | | | | | | | | | This reverts commit b3cf92aa916ee0537ee37723c23a9897ac9cd3e0. The reverted commit prevented constant-folding of reciprocal expressions when the reciprocated expression was 0. However, since the spec allows division by zero, constant-folding *is* permissible in this case. From Section 5.9 of the GLSL 1.20 spec: Dividing by zero does not cause an exception but does result in an unspecified value.
* glsl: Avoid division-by-zero during constant-foldingChad Versace2011-02-021-1/+19
| | | | | | | | | | | | | | | | | | | | | Avoid division-by-zero when constant-folding the following expression types: ir_unop_rsq ir_binop_div ir_binop_mod Fixes bugs: https://bugs.freedesktop.org//show_bug.cgi?id=33306 https://bugs.freedesktop.org//show_bug.cgi?id=33508 Fixes Piglit tests: glslparsertest/glsl2/div-by-zero-01.frag glslparsertest/glsl2/div-by-zero-02.frag glslparsertest/glsl2/div-by-zero-03.frag glslparsertest/glsl2/modulus-zero-01.frag glslparsertest/glsl2/modulus-zero-02.frag NOTE: This is a candidate for the 7.9 and 7.10 branches.
* glsl: Fix constant-folding for reciprocal expressionsChad Versace2011-02-021-6/+10
| | | | | | | | | | | | | | | Do not constant-fold a reciprocal if any component of the reciprocated expression is 0. For example, do not constant-fold `1 / vec4(0, 1, 2, 3)`. Incorrect, previous behavior ---------------------------- Reciprocals were constant-folded even when some component of the reciprocated expression was 0. The incorrectly applied arithmetic was: 1 / 0 := 0 For example, 1 / vec4(0, 1, 2, 3) = vec4(0, 1, 1/2, 1/3) NOTE: This is a candidate for the 7.9 and 7.10 branches.
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-5/+5
|
* glsl: Add ir_quadop_vector expressionIan Romanick2010-11-191-0/+18
| | | | | | | | | | The vector operator collects 2, 3, or 4 scalar components into a vector. Doing this has several advantages. First, it will make ud-chain tracking for components of vectors much easier. Second, a later optimization pass could collect scalars into vectors to allow generation of SWZ instructions (or similar as operands to other instructions on R200 and i915). It also enables an easy way to generate IR for SWZ instructions in the ARB_vertex_program assembler.
* glsl: Eliminate assumptions about size of ir_expression::operandsIan Romanick2010-11-191-1/+1
| | | | This may grow in the near future.
* glsl: Add ir_unop_sin_reduced and ir_unop_cos_reducedIan Romanick2010-11-191-0/+2
| | | | | | | | | | | | The operate just like ir_unop_sin and ir_unop_cos except that they expect their inputs to be limited to the range [-pi, pi]. Several GPUs require this limited range for their sine and cosine instructions, so having these as operations (along with a to-be-written lowering pass) helps this architectures. These new operations also matche the semantics of the GL_ARB_fragment_program SCS instruction. Having these as operations helps in generating GLSL IR directly from assembly fragment programs.
* glsl: Remove the ir_binop_cross opcode.Kenneth Graunke2010-11-171-12/+8
|
* glsl: Fix constant expression handling for <, >, <=, >= on vectors.Kenneth Graunke2010-11-171-48/+60
| | | | | | | | | | | | | | | | | ir_binop_less, ir_binop_greater, ir_binop_lequal, and ir_binop_gequal are defined to work on vectors as well as scalars, as long as the two operands have the same type. This is evident from both ir_validate.cpp and our use of these opcodes in the GLSL lessThan, greaterThan, lessThanEqual, greaterThanEqual built-in functions. Found by code inspection. Not known to fix any bugs. Presumably, our tests for the built-in comparison functions must pass because C.E. handling is done on the ir_call of "greaterThan" rather than the inlined opcode. The C.E. handling of the built-in function calls is correct. NOTE: This is a candidate for the 7.9 branch.
* glsl: fix assorted MSVC warningsBrian Paul2010-11-151-13/+13
|
* glsl: Add constant expression handling for asinh, acosh, and atanh.Kenneth Graunke2010-11-151-0/+12
|
* glsl: Fix ir_expression::constant_expression_value()Chad Versace2010-11-091-0/+3
| | | | | When the type of the ir_expression is error_type, return NULL. This fixes bug 31371.
* glsl: Implement constant expr evaluation for bitwise logic opsChad Versace2010-10-151-0/+54
| | | | | | | | Implement by adding the following cases to ir_exporession::constant_expression_value(): - ir_binop_bit_and - ir_binop_bit_or - ir_binop_bit_xor
* glsl: Implement constant expr evaluation for bit-shift opsChad Versace2010-10-151-0/+48
| | | | | | | Implement by adding the following cases to ir_expression::constant_expression_value(): - ir_binop_lshfit - ir_binop_rshfit
* glsl: Implement constant expr evaluation for bitwise-notChad Versace2010-10-151-0/+15
| | | | | Implement by adding a case to ir_expression::constant_expression_value() for ir_unop_bit_not.
* glsl: Initialize variable in ir_derefence_array::constant_expression_valueVinson Lee2010-10-131-1/+1
| | | | | | | Completely initialize data passed to ir_constant constructor. Fixes piglit glsl-mat-from-int-ctor-03 valgrind uninitialized value error on softpipe.
* glsl: Fix broken handling of ir_binop_equal and ir_binop_nequal.Kenneth Graunke2010-09-201-25/+30
| | | | | | | | When ir_binop_all_equal and ir_binop_any_nequal were introduced, the meaning of these two opcodes changed to return vectors rather than a single scalar, but the constant expression handling code was incorrectly written and only worked for scalars. As a result, only the first component of the returned vector would be properly initialized.
* glsl: introduce ir_binop_all_equal and ir_binop_any_equal, allow vector cmpsLuca Barbieri2010-09-131-4/+34
| | | | | | | | | | | | | | | | | Currently GLSL IR forbids any vector comparisons, and defines "ir_binop_equal" and "ir_binop_nequal" to compare all elements and give a single bool. This is highly unintuitive and prevents generation of optimal Mesa IR. Hence, first rename "ir_binop_equal" to "ir_binop_all_equal" and "ir_binop_nequal" to "ir_binop_any_nequal". Second, readd "ir_binop_equal" and "ir_binop_nequal" with the same semantics as less, lequal, etc. Third, allow all comparisons to acts on vectors. Signed-off-by: Ian Romanick <[email protected]>
* glsl: Move is_builtin flag back to ir_function_signature.Kenneth Graunke2010-09-071-1/+1
| | | | | | | | | | | This effectively reverts b6f15869b324ae64a00d0fe46fa3c8c62c1edb6c. In desktop GLSL, defining a function with the same name as a built-in hides that built-in function completely, so there would never be built-in and user function signatures in the same ir_function. However, in GLSL ES, overloading built-ins is allowed, and does not hide the built-in signatures - so we're back to needing this.
* glsl: Initialize variable in ir_swizzle::constant_expression_value.Vinson Lee2010-08-291-1/+1
| | | | | | | Complete initialize data passed to ir_constant constructor. Fixes piglit glsl-mat-from-int-ctor-02 valgrind unintialized variable error with softpipe and llvmpipe.
* glsl: Move is_built_in flag from ir_function_signature to ir_function.Kenneth Graunke2010-08-261-1/+1
| | | | | | Also rename it to "is_builtin" for consistency. Signed-off-by: Ian Romanick <[email protected]>
* glsl: Include main/core.h.Chia-I Wu2010-08-241-1/+1
| | | | Make glsl include only main/core.h from core mesa.
* mesa: Add new ir_unop_any() expression operation.Eric Anholt2010-08-231-0/+9
| | | | | | | The previous any() implementation would generate arg0.x || arg0.y || arg0.z. Having an expression operation for this makes it easy for the backend to generate something easier (DPn + SNE for 915 FS, .any predication on 965 VS)
* ir_constant_expression: Implement equal/notEqual for booleans.Kenneth Graunke2010-08-181-0/+6
| | | | | | Calls to equal(bvec, bvec) or notEqual(bvec, bvec) previously caused an assertion. Fixes piglit tests glsl-const-builtin-equal-bool and glsl-const-builtin-notEqual-bool.
* glsl2: Skip talloc_parent in constant_expression of non-constant arrays.Eric Anholt2010-08-041-1/+1
|
* glsl2: Make the clone() method take a talloc context.Eric Anholt2010-08-041-2/+5
| | | | | | | In most cases, we needed to be reparenting the cloned IR to a different context (for example, to the linked shader instead of the unlinked shader), or optimization before the reparent would cause memory usage of the original object to grow and grow.
* glsl2: Fix typo in clamp() constant builtin using uint instead of int.Eric Anholt2010-08-021-1/+1
| | | | | I take back the bad things I've said about the signed/unsigned comparison warning now.
* glsl2: Don't consider uniform initializers as constant expressions.Eric Anholt2010-08-021-0/+6
| | | | | We were happily optimizing away the body of glsl-uniform-initializer-* to never use the uniforms.
* ir_constant_expression: Add support for the "outerProduct" builtin.Kenneth Graunke2010-07-281-1/+8
|
* ir_constant_expression: Add support for the "mix" builtin.Kenneth Graunke2010-07-281-1/+13
| | | | Both 1.10 and 1.30 variants.
* ir_constant_expression: Add support for the "transpose" builtin.Kenneth Graunke2010-07-281-1/+8
|
* ir_constant_expression: Add support for the "smoothstep" builtin.Kenneth Graunke2010-07-281-1/+15
|
* ir_constant_expression: Add support for the "clamp" builtin.Kenneth Graunke2010-07-281-1/+24
|
* ir_constant_expression: Add support for the "step" builtin.Kenneth Graunke2010-07-281-1/+5
|
* ir_constant_expression: Add support for the "faceforward" builtin.Kenneth Graunke2010-07-281-1/+4
|
* ir_constant_expression: Add support for the "refract" builtin.Kenneth Graunke2010-07-281-1/+11
|
* ir_constant_expression: Add support for the "reflect" builtin.Kenneth Graunke2010-07-281-1/+4
|
* ir_constant_expression: Add support for the "normalize" builtin.Kenneth Graunke2010-07-281-1/+8
|
* ir_constant_expression: Add support for the "matrixCompMult" builtin.Kenneth Graunke2010-07-281-1/+3
|
* ir_constant_expression: Simplify code that implements the "dot" builtin.Kenneth Graunke2010-07-281-1/+1
| | | | There's no need to use an ir_expression; we have a handy C function.
* ir_constant_expression: Add support for the "length" builtin.Kenneth Graunke2010-07-281-1/+1
|
* ir_constant_expression: Extract dot product calculation for reuse.Kenneth Graunke2010-07-281-7/+14
|
* ir_constant_expression: Remove support for dot products of integers.Kenneth Graunke2010-07-281-13/+2
| | | | | This shouldn't be required since dot is only defined for floating point types, even in GLSL 4.0.