Commit Graph

37100 Commits

Author SHA1 Message Date
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
Eric Anholt
47f3f22311 glsl2: Add support for floating constants like "1f".
Fixes glsl-floating-constant-120.
2010-08-02 11:26:43 -07:00
Eric Anholt
960ba0014a glsl2: Initialize the ARB_fcc fields of ir_variable.
Fixes intermittent failure in glsl-arb-fragment-coord-conventions.
2010-08-02 11:20:32 -07:00
Eric Anholt
b8db38e1c4 glsl2: Also initialize the identifier field of parameter_declarator.
The non-named parameter grammar understandably doesn't set the
identifier field.  Fixes intermittent failures about void main(void)
{} having a named void parameter.
2010-08-02 11:04:54 -07:00
Eric Anholt
004e924014 glsl2: Fix spelling of "precision" in error output. 2010-08-02 10:59:46 -07:00
Eric Anholt
f311d8e9e9 glsl2: Don't add mesa/program/ as an include dir. Let includes say program/. 2010-08-02 10:59:46 -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
Aras Pranckevicius
b35703df10 glsl2: initialize is_array and array_size of ast_parameter_declarator
The non-array path of glsl_parser.ypp wasn't setting is_array to false.
2010-08-02 10:59:42 -07:00
Eric Anholt
6a41626e90 glsl2: Make non-square matrix keywords not keywords pre-120.
Fixes glsl-mat-110.
2010-08-01 19:11:10 -07:00
Eric Anholt
b42519108d ir_to_mesa: Add support for MESA_GLSL=log.
This is the option that dumps shader source to files in the current
directory.
2010-08-01 11:41:02 -07:00
Eric Anholt
93b10bd353 glcpp: Add a testcase for the failure in compiling xonotic's shader.
gcc and mesa master agree that this is OK.
2010-08-01 11:40:07 -07:00
Eric Anholt
f6b03f3235 glsl2: Do algebraic optimizations after linking as well.
Linking brings in inlining of builtins, so we weren't catching the
(rcp(/sqrt(x)) -> rsq(x)) without it.
2010-07-31 15:52:24 -07:00
Eric Anholt
784695442c glsl2: Add new tree grafting optimization pass. 2010-07-31 15:52:21 -07:00
Eric Anholt
d72edc4ddd glsl2: Factor out the variable refcounting part of ir_dead_code.cpp. 2010-07-31 15:52:21 -07:00
Aras Pranckevicius
1c325af4d6 glsl2: Fix stack smash when ternary selection is used. 2010-07-31 12:00:01 -07:00
Eric Anholt
3fa1b85196 glsl2: Fix the implementation of atan(y, x).
So many problems here.  One is that we can't do the quadrant handling
for all the channels at the same time, so we call the float(y, x)
version multiple times.  I'd also left out the x == 0 handling.  Also,
the quadrant handling was broken for y == 0, so there was a funny
discontinuity on the +x side if you plugged in obvious values to test.

I generated the atan(float y, float x) code from a short segment of
GLSL and pasted it in by hand.  It would be nice to automate that
somehow.

Fixes:
glsl-fs-atan-1
glsl-fs-atan-2
2010-07-30 15:19:00 -07:00
Carl Worth
ec9675ec53 ast: Initialize location data in constructor of all ast_node objects.
This prevents using uninitialized data in _msea_glsl_error in some
cases, (including at least 6 piglit tests). Thanks to valgrind for
pointing out the problem!
2010-07-30 15:03:37 -07:00
Eric Anholt
40f57c2bec ir_to_mesa: Add the function name as a comment to BGNSUB and ENDSUB. 2010-07-30 14:57:44 -07:00
Eric Anholt
5e5583ee06 glsl2: Update the callee pointer of calls to newly-linked-in functions.
Otherwise, ir_function_inlining will see the body of the function from
the unlinked version of the shader, which won't have had the lowering
passes done on it or linking's variable remapping.
2010-07-30 14:57:22 -07:00
Kenneth Graunke
939a1807fe glsl2: Initialize ir_function_signature::is_built_in.
Fixes a valgrind error.
2010-07-30 13:30:11 -07:00
Kenneth Graunke
805cbf3922 glcpp: Don't look for backslashes before the beginning of the string.
Fixes a valgrind error.
2010-07-30 13:26:14 -07:00
Eric Anholt
0cf545ec69 glsl2: Do ir_if_return on the way out, not the way in.
The problem with doing it on the way in is that for a function with
multiple early returns, we'll move an outer block in, then restart the
pass, then move the two inside returns out, then never move outer
blocks in again because the remaining early returns are inside an else
block and they don't know that there's a return just after their
block.  By going inside-out, we get the early returns stacked up so
that they all move out with a series of
move_returns_after_block().

Fixes (on i965):
glsl-fs-raytrace-bug27060
glsl-vs-raytrace-bug26691
2010-07-29 15:56:17 -07:00
Eric Anholt
a62ef12ef2 glsl2: Make sure functions end with a return before doing ir_if_return.
This catches a few remaining functions that weren't getting inlined,
generally operating on global or out variables and using an early
return to skip work when possible.

Fixes for i965:
glsl1-function with early return (3)
2010-07-29 15:19:44 -07:00
Eric Anholt
18964618a1 glsl2: Make ir_if_return handle if () { return } else { not return }
This makes many remaining functions inlinable.

Fixes for i965:
glsl1-function with early return (1)
glsl1-function with early return (2)
2010-07-29 15:19:37 -07:00
Eric Anholt
92a3768cef glsl2: Refactor a bit of ir_if_return for the next changes. 2010-07-29 15:19:37 -07:00
Eric Anholt
806cb9f952 ir_to_mesa: Don't emit a duplicate return at the end of a function.
It was harmless, but ugly.
2010-07-29 15:19:37 -07:00
Eric Anholt
0e19922558 glsl2: Allow use of _mesa_print_ir without a parse state on hand. 2010-07-29 15:09:31 -07:00
Eric Anholt
ee4b4bab68 ir_constant_variable: Don't mark variable from outside our scope as constant.
Fixes (with software, except for alpha):
glsl1-function with early return(3)
2010-07-29 15:09:28 -07:00
Eric Anholt
bf496862be glsl2: When dumping IR for debug, indent nested blocks.
No more trying to match parens in my head when looking at the body of
a short function containing an if statement.
2010-07-29 14:38:04 -07:00
Eric Anholt
9a8eb684d4 glsl2: When dumping IR for debug, skip all the empty builtin prototypes. 2010-07-29 14:38:04 -07:00
Eric Anholt
62c4763b70 glsl2: Fix spelling of "sentinel." 2010-07-29 14:02:19 -07:00
Eric Anholt
fa33d0b854 glsl2: Fix spelling of "initializer." 2010-07-29 14:02:19 -07:00
Eric Anholt
4285247f12 glsl2: Remove an inlined unvalued return statement.
We already have asserts that it was the last call in the function, so
it's safe to remove after it got cloned in.

Fixes:
glsl-fs-functions-4.
2010-07-29 14:02:10 -07:00
Eric Anholt
d6942460ce glsl2: Actually fix glsl-version-define. 2010-07-28 17:36:07 -07:00
Eric Anholt
d4a04f3155 glcpp: Add __VERSION__ define to the current language version.
Fixes:
glsl-version-define
glsl-version-define-110
glsl-version-define-120
2010-07-28 17:32:39 -07:00
Eric Anholt
8605c297cf glcpp: Print integer tokens as decimal, not hex. 2010-07-28 17:32:11 -07:00
Eric Anholt
192b57df8c glsl2: Make lowp, mediump, highp, and precision identifiers pre-1.20.
Fixes glsl-precision-110.
2010-07-28 17:32:11 -07:00
Kenneth Graunke
35cc8b98ec glsl2/Makefile: Append to DEFINES rather than replacing them.
Otherwise, we lose DEBUG, which causes mtypes.h to set NDEBUG, which
causes assertions to not happen, which is no fun for anyone.
2010-07-28 16:48:04 -07:00
Eric Anholt
859fd56245 ir_to_mesa: Respect the driver if it rejects a shader. 2010-07-28 15:51:36 -07:00
Kenneth Graunke
56af4e56e3 glsl2: Fix outerProduct builtin.
The type signatures were completely backwards.
2010-07-28 15:46:29 -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