Commit Graph

33 Commits

Author SHA1 Message Date
Kenneth Graunke
9935fe705d glsl: Remove the ir_binop_cross opcode. 2010-11-17 13:59:17 -08:00
Brian Paul
b2578ef873 glsl: add ir_unop_round_even case to silence unhandled enum warning 2010-10-15 15:44:01 -06:00
Chad Versace
e2c1fe3eb0 glsl: Fix ir validation for bit logic ops
In ir_validate::visit_leave(), the cases for
    - ir_binop_bit_and
    - ir_binop_bit_xor
    - ir_binop_bit_or
were incorrect. It was incorrectly asserted that both operands must be the
same type, when in fact one may be scalar and the other a vector. It was also
incorrectly asserted that the resultant type was the type of the left operand,
which in fact does not hold when the left operand is a scalar and the right
operand is a vector.
2010-10-15 00:20:18 -07:00
Chad Versace
5c4c36f7f3 glsl: Implement ast-to-hir for binary shifts in GLSL 1.30
Implement by adding the following cases to ast_expression::hir():
    - ast_lshift
    - ast_rshift
Also, implement ir validation for the new operators by adding the following
cases to ir_validate::visit_leave():
    - ir_binop_lshift
    - ir_binop_rshift
2010-10-15 00:20:18 -07:00
Eric Anholt
5e8ed7a79b glsl: Add validation that a swizzle only references valid channels.
Caught the bug in the previous commit.
2010-09-27 15:52:56 -07:00
Eric Anholt
b39e6f33b6 glsl: Rework assignments with write_masks to have LHS chan count match RHS.
It turns out that most people new to this IR are surprised when an
assignment to (say) 3 components on the LHS takes 4 components on the
RHS.  It also makes for quite strange IR output:

(assign (constant bool (1)) (x) (var_ref color) (swiz x (var_ref v) ))
(assign (constant bool (1)) (y) (var_ref color) (swiz yy (var_ref v) ))
(assign (constant bool (1)) (z) (var_ref color) (swiz zzz (var_ref v) ))

But even worse, even we get it wrong, as shown by this line of our
current step(float, vec4):

(assign (constant bool (1)) (w)
	(var_ref t)
	(expression float b2f (expression bool >=
		    (swiz w (var_ref x))(var_ref edge))))

where we try to assign a float to the writemasked-out x channel and
don't supply anything for the actual w channel we're writing.  Drivers
right now just get lucky since ir_to_mesa spams the float value across
all the source channels of a vec4.

Instead, the RHS will now have a number of components equal to the
number of components actually being written.  Hopefully this confuses
everyone less, and it also makes codegen for a scalar target simpler.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2010-09-22 13:09:51 -07:00
Brian Paul
1739124159 glsl2: silence compiler warnings in printf() calls
Such as: "ir_validate.cpp:143: warning: format ‘%p’ expects type ‘void*’,
but argument 2 has type ‘ir_variable*’"
2010-09-20 08:22:54 -06:00
Brian Paul
1c0644e9da glsl2: add case for ir_unop_noise
Silences a compiler warning.  Still need to add some assertions
for this case.
2010-09-14 09:15:20 -06: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
368dc76f04 ir_validate: Ensure ir_binop_dot is only used on vector types. 2010-09-08 12:09:42 -07:00
Ian Romanick
53acbd87d7 ir_validate: Validate loop control fields in ir_loop 2010-09-03 11:55:21 -07: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
José Fonseca
9349379d1a Revert "glsl2: Use stdint.h instead of inttypes.h"
This reverts commit a77a6bc008.
2010-08-14 16:01:24 +01:00
Ian Romanick
a77a6bc008 glsl2: Use stdint.h instead of inttypes.h 2010-08-13 16:22:21 -07:00
Brian Paul
9f9386d22a glsl2: added casts to silence warnings 2010-08-11 15:06:13 -06:00
Eric Anholt
bc4034b243 glsl2: Add a pass to convert exp and log to exp2 and log2.
Fixes ir_to_mesa handling of unop_log, which used the weird ARB_vp LOG
opcode that doesn't do what we want.  This also lets the multiplication
coefficients in there get constant-folded, possibly.

Fixes:
glsl-fs-log
2010-08-05 15:34:00 -07:00
Ian Romanick
6235c6a838 glsl2: Additional validation of write masks 2010-08-04 16:47:28 -07:00
Eric Anholt
c22dee7216 glsl2: Fix ir_validate validating null variable names.
An unnamed variable in a prototype will have a NULL ->name, so don't
worry about storage then.

Fixes:
CorrectFunction1.vert
CorrectParse1.frag
2010-08-03 11:47:02 -07:00
Ian Romanick
7ffe40532f glsl2: Clean-up two 'unused variable' warnings 2010-08-02 13:53:32 -07:00
Eric Anholt
ee7666b5ac glsl2: Add validation that talloc ownership of ir_* names is right. 2010-08-02 12:08:52 -07:00
Eric Anholt
e75dbf66d0 glsl2: Fix validation for ir_unop_not.
We use vector ir_unop_not to implement builtin not(), and that seems fine.
2010-08-02 12:06:34 -07:00
Aras Pranckevicius
31747155ea glsl2: Give the path within src/mesa/ for headers instead of relying on -I. 2010-08-02 10:59:46 -07:00
Eric Anholt
5533c6e380 ir_validate: Check the types of expression operations. 2010-07-27 09:43:52 -07:00
Eric Anholt
6a1401eb88 glsl2: Fix missing visit_continue return in ir_validate. 2010-07-27 00:18:57 -07:00
Eric Anholt
432b787b29 glsl2: Validate that ir_if conditions are actually bool. 2010-07-22 16:24:49 -07:00
Eric Anholt
f141fa63a4 glsl2: Check that nodes in a valid tree aren't error-type.
We're good at propagating error types around, but finding when the
first one was triggered can be painful if we aren't paying attention.
2010-07-20 17:30:10 -07:00
Eric Anholt
d16044ad4d glsl2: Give IR nodes a type field.
This is a big deal for debugging if nothing else ("what class is this
ir_instruction, really?"), but is also nice for avoiding building a
whole visitor or an if (node->as_whatever() || node->as_other_thing())
chain.
2010-07-19 09:50:29 -07:00
Ian Romanick
506880bc32 ir_validate: Also perform usual checks on ir_dereference_variable nodes 2010-07-12 15:46:16 -07:00
Ian Romanick
8baf21b1a4 ir_validate: Validate that varibles are declared before used in IR 2010-07-12 15:43:50 -07:00
Ian Romanick
c67016de96 ir_validate: Additional function related invariant checks
Add two invariant checks related to functions and function signatures:

1. Ensure that function definitions (ir_function) are not nested.

2. Ensure that the ir_function pointed to by an ir_function_signature
is the one that contains it in its signatures list.
2010-07-12 15:19:29 -07:00
Ian Romanick
d1a1ee583e Add hash table helper functions for using pointers as hash keys 2010-07-06 15:00:46 -07:00
Eric Anholt
3d6012303c glsl2: Wrap includes of C interfaces with extern "C". 2010-06-24 17:23:19 -07:00
Eric Anholt
2928588267 glsl2: Move the compiler to the subdirectory it will live in in Mesa. 2010-06-24 15:36:00 -07:00