Commit Graph

100 Commits

Author SHA1 Message Date
Ian Romanick 11d6f1c698 glsl: Add ir_quadop_vector expression
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.
2010-11-19 15:00:26 -08:00
Ian Romanick fc92e87b97 glsl: Eliminate assumptions about size of ir_expression::operands
This may grow in the near future.
2010-11-19 15:00:25 -08:00
Ian Romanick f2616e56de glsl: Add ir_unop_sin_reduced and ir_unop_cos_reduced
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.
2010-11-19 15:00:25 -08:00
Kenneth Graunke 9935fe705d glsl: Remove the ir_binop_cross opcode. 2010-11-17 13:59:17 -08:00
Kenneth Graunke e16c9d5d03 glsl: Fix constant expression handling for <, >, <=, >= on vectors.
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.
2010-11-17 11:58:56 -08:00
Brian Paul 88f482a839 glsl: fix assorted MSVC warnings 2010-11-15 18:48:43 -07:00
Kenneth Graunke 3108095198 glsl: Add constant expression handling for asinh, acosh, and atanh. 2010-11-15 14:08:58 -08:00
Chad Versace b62c1c4595 glsl: Fix ir_expression::constant_expression_value()
When the type of the ir_expression is error_type, return NULL.
This fixes bug 31371.
2010-11-09 00:50:54 -08:00
Chad Versace 4761d0d22b glsl: Implement constant expr evaluation for bitwise logic ops
Implement by adding the following cases to
ir_exporession::constant_expression_value():
    - ir_binop_bit_and
    - ir_binop_bit_or
    - ir_binop_bit_xor
2010-10-15 00:20:18 -07:00
Chad Versace adea8150a7 glsl: Implement constant expr evaluation for bit-shift ops
Implement by adding the following cases to
ir_expression::constant_expression_value():
    - ir_binop_lshfit
    - ir_binop_rshfit
2010-10-15 00:20:18 -07:00
Chad Versace 90a8b792c0 glsl: Implement constant expr evaluation for bitwise-not
Implement by adding a case to ir_expression::constant_expression_value()
for ir_unop_bit_not.
2010-10-15 00:20:18 -07:00
Vinson Lee 720bdfbceb glsl: Initialize variable in ir_derefence_array::constant_expression_value
Completely initialize data passed to ir_constant constructor.

Fixes piglit glsl-mat-from-int-ctor-03 valgrind uninitialized value
error on softpipe.
2010-10-13 14:21:08 -07:00
Kenneth Graunke 6ea16b6c51 glsl: Fix broken handling of ir_binop_equal and ir_binop_nequal.
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.
2010-09-20 17:33:13 +02:00
Luca Barbieri 4dfb89904c glsl: introduce ir_binop_all_equal and ir_binop_any_equal, allow vector cmps
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 <ian.d.romanick@intel.com>
2010-09-13 17:53:04 -07:00
Kenneth Graunke f412fac5b4 glsl: Move is_builtin flag back to ir_function_signature.
This effectively reverts b6f15869b3.

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.
2010-09-07 17:30:38 -07:00
Vinson Lee 2d0ef6bfee glsl: Initialize variable in ir_swizzle::constant_expression_value.
Complete initialize data passed to ir_constant constructor.

Fixes piglit glsl-mat-from-int-ctor-02 valgrind unintialized variable
error with softpipe and llvmpipe.
2010-08-29 12:19:57 -07:00
Kenneth Graunke b6f15869b3 glsl: Move is_built_in flag from ir_function_signature to ir_function.
Also rename it to "is_builtin" for consistency.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-08-26 09:19:48 -07:00
Chia-I Wu bfd7c9ac22 glsl: Include main/core.h.
Make glsl include only main/core.h from core mesa.
2010-08-24 11:27:29 +08:00
Eric Anholt 5e9ac94cc4 mesa: Add new ir_unop_any() expression operation.
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)
2010-08-23 13:05:53 -07:00
Kenneth Graunke d12cb77d85 ir_constant_expression: Implement equal/notEqual for booleans.
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.
2010-08-18 12:08:19 -07:00
Eric Anholt 952d0f88e1 glsl2: Skip talloc_parent in constant_expression of non-constant arrays. 2010-08-04 12:57:58 -07:00
Eric Anholt 8273bd4687 glsl2: Make the clone() method take a talloc context.
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.
2010-08-04 12:42:47 -07:00
Eric Anholt c8babd5d9b glsl2: Fix typo in clamp() constant builtin using uint instead of int.
I take back the bad things I've said about the signed/unsigned
comparison warning now.
2010-08-02 17:50:20 -07:00
Eric Anholt 5704ed27dd glsl2: Don't consider uniform initializers as constant expressions.
We were happily optimizing away the body of
glsl-uniform-initializer-* to never use the uniforms.
2010-08-02 17:47:35 -07:00
Kenneth Graunke 7ddee6a535 ir_constant_expression: Add support for the "outerProduct" builtin. 2010-07-28 15:46:29 -07:00
Kenneth Graunke 5d255e24b2 ir_constant_expression: Add support for the "mix" builtin.
Both 1.10 and 1.30 variants.
2010-07-28 15:46:29 -07:00
Kenneth Graunke b09ae5dd3f ir_constant_expression: Add support for the "transpose" builtin. 2010-07-28 15:46:29 -07:00
Kenneth Graunke 546f3a2754 ir_constant_expression: Add support for the "smoothstep" builtin. 2010-07-28 15:46:29 -07:00
Kenneth Graunke a4ca1cfb66 ir_constant_expression: Add support for the "clamp" builtin. 2010-07-28 15:46:29 -07:00
Kenneth Graunke ff58b7c9b6 ir_constant_expression: Add support for the "step" builtin. 2010-07-28 15:46:29 -07:00
Kenneth Graunke 3d5c2f0adb ir_constant_expression: Add support for the "faceforward" builtin. 2010-07-28 15:46:29 -07:00
Kenneth Graunke 04b3643dbf ir_constant_expression: Add support for the "refract" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke d60b2b03da ir_constant_expression: Add support for the "reflect" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke 53f306d573 ir_constant_expression: Add support for the "normalize" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke 8fe5f30645 ir_constant_expression: Add support for the "matrixCompMult" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke a7650af706 ir_constant_expression: Simplify code that implements the "dot" builtin.
There's no need to use an ir_expression; we have a handy C function.
2010-07-28 15:46:28 -07:00
Kenneth Graunke 5489ad086f ir_constant_expression: Add support for the "length" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke ffcec13599 ir_constant_expression: Extract dot product calculation for reuse. 2010-07-28 15:46:28 -07:00
Kenneth Graunke 4b1d77ea96 ir_constant_expression: Remove support for dot products of integers.
This shouldn't be required since dot is only defined for floating point
types, even in GLSL 4.0.
2010-07-28 15:46:28 -07:00
Kenneth Graunke 557827340a ir_constant_expression: Add support for the "greaterThanEqual" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke 7f042b9812 ir_constant_expression: Add support for the "greaterThan" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke 319f4949e0 ir_constant_expression: Add support for the "lessThanEqual" builtin. 2010-07-28 15:46:28 -07:00
Kenneth Graunke 6d897f07cf ir_constant_expression: Add support for the "lessThan" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 48a69ba057 ir_constant_expression: Add support for the "notEqual" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 0b6ef6ef6e ir_constant_expression: Add support for the "equal" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 2eaf31642c ir_constant_expression: Add support for the "distance" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 7bcaa3828f ir_constant_expression: Add support for the "degrees" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 0afe349322 ir_constant_expression: Add support for the "radians" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 20970f7dea ir_constant_expression: Add support for the "tanh" builtin. 2010-07-28 15:46:27 -07:00
Kenneth Graunke 9c9f8b2d69 ir_constant_expression: Add support for the "tan" builtin. 2010-07-28 15:46:27 -07:00