• Home
  • History
  • Annotate
  • only in /external/mesa3d/src/glsl/
History log of /external/mesa3d/src/glsl/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
765221c0d5fdb0357bf6fae3220c7d57d93f938d 28-Nov-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Track UBO block names in the symbol table.

The GLSL 1.40 spec says:

"Uniform block names and variable names declared within uniform
blocks are scoped at the program level."

Track the block name in the symbol table and emit errors when conflicts
exist.

Fixes es3conform's uniform_buffer_object_block_name_conflict test, and
fixes the piglit block-name-clashes-with-{variable,function,struct}.vert
tests.

NOTE: This is a candidate for the 9.0 branch.

v2: Fix bad constructor initialization. Noticed by Topi Pohjolainen.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 4f29169913f99252c54e1922f6d164e2ef530a58)
st_to_hir.cpp
lsl_symbol_table.cpp
lsl_symbol_table.h
d63e946587bb104e2b320fbebafe25bb969d01b8 29-Dec-2012 Johannes Obermayr <johannesobermayr@gmx.de> tests: AM_CPPFLAGS must include $(top_srcdir) instead of $(top_builddir).

Reviewed-by: Andreas Boll <andreas.boll.dev@gmail.com>
(cherry picked from commit ebcabb88cfd19b35cd1b0a327fa055fff0c1b2be)

Additionally it fixes the missing $(top_srcdir)/include in
src/glsl/tests/Makefile.am

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59383
ests/Makefile.am
6b3355c91dc24bd93b63ed6c6701faa581499810 06-Dec-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Don't add structure fields to the symbol table

I erroneously added this back in January 2011 in commit 88421589.
Looking at the commit message, I have no idea why I added it. It only
added non-array structure fields to the symbol table, so array structure
fields are treated correctly.

Fixes piglit tests structure-and-field-have-same-name.vert and
structure-and-field-have-same-name-nested.vert. It should also fix
WebGL conformance tests shader-with-non-reserved-words.

NOTE: This is a candidate for the stable release branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57622
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit ed3f237e09a42bdb55afb58d1536affad9000d76)
lsl_parser.yy
8333a7b6e3a8a49ef5b7b673ca0c0bb3369b5222 02-Jan-2013 Adam Jackson <ajax@redhat.com> glcpp: Typo fix.

Note: this is a candidate for the 9.0 stable branch.

Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 86b6964ef9839f1bd5a05efe47712843c97196ca)
lcpp/Makefile.am
7eddf861859135caea9cea20576d024909660d95 02-Jan-2013 Adam Jackson <ajax@redhat.com> glcpp: Fix visibility CFLAGS in automake

Note: this is a candidate for the 9.0 stable branch.

Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 0daabd52394899ec4947dc2cf3119201d2e79b1c)
lcpp/Makefile.am
a096942592142c98ccba5f82cea41d53df328137 30-Nov-2012 Dave Airlie <airlied@gmail.com> glsl: fix uninitialised variable from constructor

Coverity pointed out this uninitialised class member.

Note: This is a candidate for stable branches.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit f3476ec8fa5a94d469a12318c537b13ce9cc5a45)
r_function_detect_recursion.cpp
eadadecbaad7f72dbdb122385447e3f4e251837d 30-Nov-2012 Dave Airlie <airlied@gmail.com> glsl: initialise killed_all field.

coverity pointed out this field was being used uninitialised.

Note: This is a candidate for stable branches.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 906670a7906a785210c872f637239bf4afa5b63d)
pt_constant_propagation.cpp
a00623174b629525fa5a9ba651ba31809b23b6e7 30-Nov-2012 Dave Airlie <airlied@gmail.com> glsl: fix cut-n-paste error in error handling. (v2)

Reported by coverity scan.

v2: fix second case

Note: This is a candidate for stable branches.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit e85c9a4d2874a302195c66742b446f0645440c43)
r_validate.cpp
a3f5601465086bfcda4e68c3c55a284dd84879c6 06-Nov-2012 Matt Turner <mattst88@gmail.com> glcpp: Reject garbage after #else and #endif tokens

Previously we were accepting garbage after #else and #endif tokens when
the previous preprocessor conditional evaluated to false (eg, #if 0).

When the preprocessor hits a false conditional, it switches the lexer
into the SKIP state, in which it ignores non-control tokens. The parser
pops the SKIP state off the stack when it reaches the associated #elif,
#else, or #endif. Unfortunately, that meant that it only left the SKIP
state after the lexing the entire line containing the #token and thus
would accept garbage after the #token.

To fix this we use a mid-rule, which is executed immediately after the
#token is parsed.

NOTE: This is a candidate for the stable branch
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56442
Fixes: preprocess17_frag.test from oglconform
Reviewed-by: Carl Worth <cworth@cworth.org> (glcpp-parse.y)
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 060e69679925f171cfcc2a5f84fab1d833a7e804)
lcpp/glcpp-parse.y
lcpp/tests/102-garbage-after-endif.c
lcpp/tests/102-garbage-after-endif.c.expected
lcpp/tests/103-garbage-after-else.c
lcpp/tests/103-garbage-after-else.c.expected
a908f4a75401284dd45bf559de18c83adaacb335 22-Oct-2012 Kenneth Graunke <kenneth@whitecape.org> glcpp: Don't use infinite lookhead for #define differentiation.

Previously, we used lookahead patterns to differentiate:

#define FOO(x) function macro
#define FOO (x) object macro

Unfortunately, our rule for function macros:

{HASH}define{HSPACE}+/{IDENTIFIER}"("

relies on infinite lookahead, and apparently triggers a Flex bug where
the generated code overflows a state buffer (see YY_STATE_BUF_SIZE).

There's no need to use infinite lookahead. We can simply change state,
match the identifier, and use a single character lookahead for the '('.
This apparently makes Flex not generate the giant state array, which
avoids the buffer overflow, and should be more efficient anyway.

Fixes piglit test 17000-consecutive-chars-identifier.frag.

NOTE: This is a candidate for every release branch ever.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Carl Worth <cworth@cworth.org>
(cherry picked from commit 9142ade15416415f2d5eb20b093b898c649cd2bb)
lcpp/glcpp-lex.l
lcpp/glcpp-parse.y
895a5873d141c726e2e81ba53d5b757e4708fb29 24-Oct-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Allow ir_if in the linker's move_non_declarations function.

Global initializers using the ?: operator with at least one non-constant
operand generate ir_if statements. For example,

float foo = some_boolean ? 0.0 : 1.0;

becomes:

(declare (temporary) float conditional_tmp)
(if (var_ref some_boolean)
((assign (x) (var_ref conditional_tmp) (constant float (0.0))))
((assign (x) (var_ref conditional_tmp) (constant float (1.0)))))

This pattern is necessary because the second or third arguments could be
function calls, which create statements (not expressions).

The linker moves these global initializers into the main() function.
However, it incorrectly had an assertion that global initializer
statements were only assignments, calls, or temporary variable
declarations. As demonstrated above, they can be if statements too.

Other than the assertion, everything works fine. So remove it.

Fixes new Piglit test condition-08.vert, as well as an upcoming
game that will be released on Steam.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit b45a68eebf3cf7227fc70082cb1e796041fc81ab)
inker.cpp
94cc306e41a2565b1dc7d410713ac78a9f1edaf3 23-Oct-2012 Matt Turner <mattst88@gmail.com> ralloc: Annotate printf functions with PRINTFLIKE(...)

This is a squash of the following two commits:

ralloc: Annotate printf functions with PRINTFLIKE(...)

Catches problems such as (in the gles3 branch)

glcpp-parse.y: In function '_glcpp_parser_handle_version_declaration':
glcpp-parse.y:1990:39: warning: format '%lli' expects argument of type
'long long int', but argument 4 has type 'int' [-Wformat]

As a side-effect, remove ralloc.c's likely/unlikely macros and just use
the ones from main/compiler.h.

NOTE: This is a candidate for the release branches.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 41b14d125196e75cdd4599a4c1069b41e7000d48)

and

src/glsl/tests/Makefile.am: Specify -I... in AM_CPPFLAGS

When specifying per-target CFLAGS (e.g., ralloc_test_CFLAGS) AM_CFLAGS
are not used. AM_CPPFLAGS should be used for includes anyway.

Fixes a build problem since 41b14d125:

CC ralloc_test-ralloc.o
In file included from ../../../src/glsl/ralloc.c:42:0:
../../../src/glsl/ralloc.h:57:27: fatal error: main/compiler.h: No such file or directory

Acked-by: Paul Berry <stereotype441@gmail.com>
(cherry picked from commit 67f1e7bf5f5d1482cb8684dd5a405b7bab5b1f34)
alloc.c
alloc.h
ests/Makefile.am
03cfc8d66002f653d5a946521c664b4050f861d3 27-Sep-2012 Matt Turner <mattst88@gmail.com> build: Build src/glsl with visibility CFLAGS
(cherry picked from commit 8746f641bb47d210fa16bb99aeb8150b06aff674)
akefile.am
421dda800de3aff588e97ccb6398b94e780590cd 19-Sep-2012 Matt Turner <mattst88@gmail.com> build: Use PTHREAD_LIBS and PTHREAD_CFLAGS
(cherry picked from commit b6651ae6ad314a93287e431a41f5c7a8f8f6c855)

Conflicts:

src/mesa/main/tests/Makefile.am
ests/Makefile.am
e642d61d130b725c0c3efbc87f86a4968311ba2a 15-Sep-2012 Brian Paul <brianp@vmware.com> scons: add new -p (prefix) options for yacc

These were recently added to the Makefiles.
(cherry picked from commit e78ebbc5f9448d459b57884d90b0a6496294c1dd)
Conscript
7cfd42cefe1949af51ecced9891f415eca2c0e66 14-Sep-2012 Dave Airlie <airlied@redhat.com> mesa/glsl: rename preprocess to glcpp_preprocess

This symbol with dricore escapes into the namespace, its too generic,
we should prefix it with something just to be nice.

Should be applied to stable + 9.0

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 88b0790b1ae8864d4ec6196b3939498bbffdbb5f)
lcpp/glcpp.c
lcpp/glcpp.h
lcpp/pp.c
lsl_parser_extras.h
ain.cpp
est_optpass.cpp
8f7990c5f2ca25e42c7fefff6312bee2ff77e134 14-Sep-2012 Dave Airlie <airlied@gmail.com> glcpp: fix abuse of yylex

So glcpp tried to workaround yylex its own way, but failed,
do it properly.

This fixes another crash found after fixing the first crash.

this is a candidate for 9.0 and stable branches

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 53d46bc787318ccf9911fdd1d5fe99ee4db7f41a)
lcpp/Makefile.am
lcpp/glcpp-parse.y
42ef3f68c9621eb713f154955dccabacd6e1e0ef 01-Sep-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Generate compile errors for explicit blend indices < 0 or > 1.

According to the GLSL 4.30 specification, this is a compile time error.
Earlier specifications don't specify a behavior, but since 0 and 1 are
the only valid indices for dual source blending, it makes sense to
generate the error.

Fixes (the fixed version of) piglit's layout-12.frag.

NOTE: This is a candidate for the 9.0 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
(cherry picked from commit 354f2cb5c7330a7d43cf0b177daf758d2aa31e0a)
st_to_hir.cpp
c824804c6f10eeb58ae91033682ca871c0e373c4 29-Aug-2012 Brian Paul <brianp@vmware.com> glsl: s/class/struct/ for ast_type_qualifier

To silence an MSVC compiler warning about class vs. struct.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser_extras.h
ff996cafce511dd8a6c4e066e409c23e147a670c 15-Aug-2012 Stéphane Marchesin <marcheu@chromium.org> glsl/linker: Avoid buffer over-run in parcel_out_uniform_storage::visit_field

When too may uniforms are used, the error will be caught in
check_resources (src/glsl/linker.cpp).

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Benoit Jacob <bjacob@mozilla.com>
ink_uniforms.cpp
2ddfca98378a1eb4044e8e9d7168d73443709068 17-Aug-2012 Tapani Pälli <tapani.palli@intel.com> build/glsl: fix android build v2

Commit 77a3efc6b907943903190b385fdf107c4acfcdca broke android build that
sets its own value for GLSL_SRCDIR before including Makefile.sources.
Patch moves overriding the value after include, this works as GLSL_SRCDIR
variable gets expanded only later.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
ndroid.mk
85d355f1220443c9efdf2d759f23512a7c691a3e 01-Aug-2012 Matt Turner <mattst88@gmail.com> build: Fix out-of-tree generation of builtin_function.cpp

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
akefile.am
77a3efc6b907943903190b385fdf107c4acfcdca 18-Jul-2012 Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> build/glsl: fix location of generated files.

Like in src/mesa, use GLSL_BUILDDIR/GLSL_SRCDIR to unambiguously
distinguish between in-tree and generated files.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
akefile.am
akefile.sources
lcpp/Makefile.am
803262a5f55ca5b94a09dfe8f35e64a579778209 26-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Refuse to parse uniform block declarations when UBOs aren't available.

Fixes piglit
GL_ARB_uniform_buffer_object/compiler/extension-disabled-block.frag

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser.yy
e45f1b11c081a7b965bf58539d2dbcc231d543f4 25-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Align GL_UNIFORM_BLOCK_DATA_SIZE according to std140 rules.

Fixes piglit GL_ARB_uniform_buffer_object/data-size test.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
86e0045578cd8d8be7736a8f56e2b51d61bda32a 23-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Only flag RowMajor on matrix-type variables.

We were only propagating it to the API when the variable was a matrix type,
but we were still tripping over it in lower_ubo_reference when it was set on a
vector.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
ffb2d430596258aaeaf3b7ae7f295036ea4094d5 23-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Fix calculation of std140 offset alignment for mat2s.

We were getting the base offset of a vec2, not of a vec2[2] like the quoted
spec text says we should.

v2: Fix swapped then/else cases.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_types.cpp
300315fe69ba275dda8a4786783c2bdd007d0758 23-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Fix glGetActiveUniformsiv(GL_UNIFORM_BLOCK_INDEX).

Previously, we were returning the index into the UniformBlocks of one of the
linked shaders, when it's supposed to be the program global index.

Fixes piglit getactiveuniformsiv-uniform_block_index.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
a75f2681d26aecad185895c1c2f13dd542281ff9 11-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Add a lowering pass to turn complicated UBO references to vector loads.

v2: Reduce the impenetrable code in emit_ubo_loads() by 23 lines by keeping
the ir_variable as the variable part of the offset from handle_rvalue(),
and track the constant offsets from that with a plain old integer value,
avoiding a bunch of temporary variables in the array and struct handling.
Also, fix file description doxygen.
v3: Fix a row vs col typo, and fix spelling in a comment.

Reviewed-by: Eric Anholt <eric@anholt.net>
akefile.sources
r_optimization.h
ower_ubo_reference.cpp
8c2a9838355cfd02356bf7b22eead408d909fe25 20-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Add a variant of the rvalue visitor for handle_rvalue() on the way down.

For the UBO lowering pass, I want to see the whole dereference chain for
replacing, not the innermost ir_dereference_variable.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_rvalue_visitor.cpp
r_rvalue_visitor.h
2ea3ab14f2182978f471674c9dfce029d37f70a7 10-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Add a "ubo_load" expression type for fetches from UBOs.

Drivers will probably want to be able to take UBO references in a
shader like:

uniform ubo1 {
float a;
float b;
float c;
float d;
}

void main() {
gl_FragColor = vec4(a, b, c, d);
}

and generate a single aligned vec4 load out of the UBO. For intel,
this involves recognizing the shared offset of the aligned loads and
CSEing them out. Obviously that involves breaking things down to
loads from an offset from a particular UBO first. Thus, the driver
doesn't want to see

variable_ref(ir_variable("a")),

and even more so does it not want to see

array_ref(record_ref(variable_ref(ir_variable("a")),
"field1"), variable_ref(ir_variable("i"))).

where a.field1[i] is a row_major matrix.

Instead, we're going to make a lowering pass to break UBO references
down to expressions that are obvious to codegen, and amenable to
merging through CSE.

v2: Fix some partial thoughts in the ir_binop comment (review by Kenneth)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
r.h
r_validate.cpp
71ba6de342b88dcf8ed3aa347da157b7724230e7 21-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Fix a reference to UniformBlocks during uniform linking.

When converting var->location from pointing at the program's UniformBlocks to
pointing at the linked shader's UniformBlocks, I missed this change. It
usually worked out in the end because the two lists happen to be the same in
many testcases.

Fixes a valgrind complaint on
oglconform ubo-compile.cpp advanced.std140.2stage

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
7e42302e7188a783221d2b17a4bb07ee89cae367 10-Jul-2012 Eric Anholt <eric@anholt.net> glsl: Update the notes on adding a new expression type.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
EADME
4bd36956f82b30b1edc299e6d6e34e1bc911af01 02-Aug-2012 José Fonseca <jfonseca@vmware.com> scons: set YACCHXXFILESUFFIX to stop needless rebuilding of the parser

Before, the GLSL parser was getting rebuilt every time that scons was
run. The problem was scons was expecting a glsl_parser.hpp file but
we were generating a glsl_parser.h file.

Signed-off-by: Brian Paul <brianp@vmware.com>
Conscript
d5c918f6adb2f7f72a759607c8f76e7616656c13 16-Jul-2012 Tomeu Vizoso <tomeu@tomeuvizoso.net> glsl: Add support for OES_standard_derivatives in GLSL ES.

Previously, we advertised the extension but the builtin functions
were enabled only for GLSL and not for ES.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52003

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/OES_standard_derivatives.frag
lsl_parser_extras.cpp
lsl_parser_extras.h
877a897adc40d98c8ee5abaaf0ae16028866c766 25-Jun-2012 Eric Anholt <eric@anholt.net> glsl: Reject linking shaders with too many uniform blocks.

Part of fixing piglit maxblocks.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
bbd1d6124d8d59d7b3f8585505ce3c01aa062e28 22-Jun-2012 Eric Anholt <eric@anholt.net> glsl: Assign array and matrix stride values according to std140 layout.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
ink_uniforms.cpp
551bdf25bc4e57bea51c54da7e31c44c507e6c9f 22-Jun-2012 Eric Anholt <eric@anholt.net> glsl: Add support for default layout qualifiers for uniforms.

I ended up having to add rallocing of the ast_type_qualifier in order
to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted
to track an ast_type_qualifier in the state.

Fixes piglit ARB_uniform_buffer_object/row-major.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st.h
st_type.cpp
lsl_parser.yy
lsl_parser_extras.cpp
lsl_parser_extras.h
7b77c64254109ff1d59a8937f8f15216c10c8cb7 22-Jun-2012 Eric Anholt <eric@anholt.net> glsl: Merge UBO layout qualifiers in a qualifier list.

Yes, you get to say things like "layout(row_major, column_major)" and
get column major.

Part of fixing piglit ARB_uniform_buffer_object/row_major.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
fafa394c15d7d4ca87fc220196dd5a57bd9cf601 19-Jun-2012 Eric Anholt <eric@anholt.net> glsl: Incorporate all UBO language changes into GLSL 1.40.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
3a90dc22d1c74e8719c95221f15043e7f3e69286 31-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Refactor #version validation to be more future-proof.

The previous implementation required a flag in _mesa_glsl_parse_state
and line of code to initialize it for every version of the shading
language we intend to support. As we look to add 150, 330, 400, 410,
420, and beyond, this gets rather unwieldy.

This patch retains the switch statement (to reject, say, #version 111),
but removes all the bits. Code to check for ctx->API == API_OPENGL_CORE
could easily be added to the 110 and 120 cases to reject those.

v2: Use _mesa_is_desktop_gl to preserve the existing behavior in the
presence of the new API_OPENGL_CORE enumeration.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
lsl_parser.yy
lsl_parser_extras.cpp
lsl_parser_extras.h
03ac5c54b55006a7014525c3dc1ebd6ed215b6be 31-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix #pragma invariant(all) language version check.

It was using state->Const.GLSL_100ES, which is set if the driver
supports ARB_ES2_compatibility or we're in ES2 mode. Instead, it should
use state->language_version, as that represents the actual GLSL version
of the shader being compiled.

Since the correct logic is < 120 && !100, just make it == 110.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
4aecd8f0316833348bb6fc392eb1aeea2410a206 24-Jul-2012 Jordan Justen <jordan.l.justen@intel.com> glsl: add support for using API_OPENGL_CORE

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.cpp
d3de40742f50340789ae0df9af582e702e963300 29-Mar-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix ir_last_opcode value.

Now that ir_quadop_vector exists, ir_last_binop and ir_last_opcode are
no longer the same. Only one place currently uses this enumeration, and
already handles ir_quadop_vector correctly.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Olivier Galibert <galibert@pobox.com>
r.h
9d998a2a592ed688c90b408604b9dbec26b752ff 22-Mar-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Request an Nx1 type instance in ir_quadop_vector lowering pass.

No types have 0 columns. The glsl_type::get_instance method contains

if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4))
return error_type;

To get a vector, use columns = 1.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Olivier Galibert <galibert@pobox.com>
ower_vector.cpp
13cb99dc73f9337358c92412aefa918c2ec16431 26-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Make bvec and ivec types accessible without using get_instance.

It's more convenient to use shortcuts like glsl_type::bvec2_type than
the longwinded glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1).

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Olivier Galibert <galibert@pobox.com>
uiltin_types.h
lsl_types.h
dcf8754cce1af09547a5976a74ba807bc6f2657c 28-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add a newline to expanded #line directives.

Otherwise, the preprocessor happily outputs

#line 2 4 <your next line of code>

and the main compiler gets horribly confused and fails to compile.

This is not the right solution (line numbers in error messages will
likely be off-by-one in certain circumstances), but until Carl comes
up with a proper fix, this gets programs running again.

Fixes regressions in Regnum Online, Overgrowth, Piglit, and others since
commit aac78ce8234d96932c38b3f48b1d828077bc0027.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51802
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51506
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41152
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/glcpp-parse.y
e72f20641a6ea7875b6021aac13e778ada3b3d50 05-Jul-2012 Oliver McFadden <oliver.mcfadden@linux.intel.com> glsl: warning: pragma `invariant(all)' not supported in GLSL ES 1.00

The OpenGL(R) ES Shading Language
Version 1.00 Revision 17 (12 May, 2009)

> 4.6.1 The Invariant Qualifier
> ... To force all output variables to be invariant, use the pragma
> #pragma STDGL invariant(all)

Signed-off-by: Oliver McFadden <oliver.mcfadden@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
lsl_parser.yy
f35e380dd240b418e17a179af73bbab74ceea784 24-Jul-2012 Anthony G. Basile <blueness@gentoo.org> Fix compile time errors when building against uclibc

Mesa misses a few checks when compiling on a uclibc system
which cause it to fall back on glibc-ism. This patch
addresses those issues.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
trtod.c
8ab5842a6d992956ee365c0e0232c6e6b907863e 02-May-2012 Eric Anholt <eric@anholt.net> glsl: Assign locations for uniforms in UBOs using the std140 rules.

Fixes piglit layout-std140.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_types.cpp
lsl_types.h
ink_uniforms.cpp
inker.cpp
inker.h
9feb403b0eb5365889cb01ca456a19247aaad502 01-May-2012 Eric Anholt <eric@anholt.net> glsl: Don't resize arrays in uniform blocks.

This is a requirement for std140 uniform blocks, and optional for
packed/shared blocks.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
0cea8a56b627cea297e4213266b57b7a1085dcca 01-May-2012 Eric Anholt <eric@anholt.net> glsl: Don't dead-code eliminiate uniforms declared in uniform blocks.

This is a requirement for std140 uniform blocks, and optional for
packed/shared blocks.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
pt_dead_code.cpp
a74507dc94f6383f2a81850866fceec108c2ab34 01-May-2012 Eric Anholt <eric@anholt.net> glsl: Propagate uniform block information into gl_uniform_storage.

Now we can actually return information on uniforms in uniform blocks
in the new queries.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_uniform.h
ink_uniforms.cpp
093b20666d73f8fc410dc7bf168ab7197756b1f5 01-May-2012 Eric Anholt <eric@anholt.net> glsl: Set the uniform_block index for the linked shader variables.

At this point in the linking, we've totally lost track of the struct
gl_uniform_buffer that this pointed to in the original unlinked
shader, so we do a nasty n^2 walk to find it the new one based on the
variable name.

Note that these point into the shader's list of gl_uniform_buffers,
not the linked program's.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
ink_uniforms.cpp
f609cf782ab5e90ddf045dc4b0da8cebf99be0d1 27-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Merge the lists of uniform blocks into the linked shader program.

This attempts error-checking, but the layout isn't done yet.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
ink_uniforms.cpp
inker.cpp
inker.h
b3c093c79c2ec49c36af37aa290d5ae452149f6e 27-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Translate the AST for uniform blocks into some IR structures.

We're going to need this structure to cross-validate the uniform
blocks between shader stages, since unused ir_variables might get
dropped. It's also the place we store the RowMajor qualifier, which
is not part of the GLSL type (since that would cause a bunch of type
equality checks to fail).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
lsl_parser_extras.h
r.cpp
r.h
r_clone.cpp
f7561e8ecd80e915150ca63c0c79a5f9839c8e12 27-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Turn UBO variable declarations into ir_variables and check qualifiers.

Fixes piglit layout-*-non-uniform and layout-*-within-block.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st.h
st_to_hir.cpp
lsl_parser.yy
lsl_parser_extras.cpp
0f1f2ff8db8c19be27b9f51f07134091e109e4b2 19-Jul-2012 Paul Berry <stereotype441@gmail.com> mesa: Set gl_fragment_program::UsesKill in do_set_program_inouts.

Previously, the code for setting this flag for GLSL programs was
duplicated in three places: brw_link_shader(), glsl_to_tgsi_visitor,
and ir_to_mesa_visitor. In addition to the unnecessary duplication,
there was a performance problem on i965: brw_link_shader() set the
flag before doing its final round of optimizations, which meant that
if the optimizations managed to eliminate all the discard operations,
the flag would still be set, resulting (at least in theory) in slower
performance.

This patch consolidates all of the code that sets UsesKill for GLSL
programs into do_set_program_inouts(), which already is doing a
similar job for UsesDFdy, and which occurs after i965's final round of
optimizations.

Non-GLSL programs (ARB programs and the state tracker's glBitmap
program) are unaffected.

Reviewed-by: Eric Anholt <eric@anholt.net>
r_set_program_inouts.cpp
d43f4181e1633d2677a8d828abd4ffc1a7c1e493 06-Jun-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove open coded version of ir_variable::interpolation_string().

Presumably the function didn't exist when we wrote this code.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
ce1d2f08f9d08bd5d49b2072a94b3d85e3169fb5 20-Jun-2012 Paul Berry <stereotype441@gmail.com> glsl: Set UsesDFdy appropriately for GLSL shaders.

This patch updates the ir_set_program_inouts_visitor so that it also
sets gl_fragment_program::UsesDFdy.

This is a bit of a hack (since dFdy() isn't an input or an output),
but there's no other obvious visitor to squeeze this functionality
into, and it would be silly to create a brand new visitor just for
this purpose.

v2: use local 'fprog' var to avoid repeated casting.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_set_program_inouts.cpp
39c4bc7fdf2af0620c36669cca32ea332ff0c8b9 17-Jul-2012 Michel Dänzer <michel.daenzer@amd.com> glsl: Drop obsolete .gitignore entries.

Helps spotting and removing the obsolete generated files, which otherwise break
the build.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
gitignore
81de0431d6f52084e01874163657e141e6beffdf 13-Jul-2012 Jon TURNEY <jon.turney@dronecode.org.uk> Fix building glsl when using automake-1.12 after 68e04cc6

Commit 68e04cc6 was tested using automake-1.11. Unfortunately, automake-1.12
made a "slightly backward-incompatible change" in the use of yacc with C++, and
for a .yy file, the generated header file is now named .hh, not .h

To work with both, write our own rule for running yacc, which generates a
header file named .h, rather than using automake's rule.

Also, remove things from BUILD_SOURCES which don't need to be there

Also, update EXCLUDE rules in doxygen/glsl.doxy, for change of generated files
from .cpp -> .cc, and glsl_lexer.h has never existed.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
akefile.am
a112ca5d5f8504310bf157d440c859676aae7753 07-Jul-2012 Jon TURNEY <jon.turney@dronecode.org.uk> automake: convert libmesa and libmesagallium

* "configure substitutions are not allowed in _SOURCES variables" in automake, so instead of
MESA_ASM_FILES, use some AM_CONDITIONALS to choose which architecture's asm sources are used
in libmesa_la_SOURCES. (Can't remove MESA_ASM_FILES autoconf variable as it's still used in
sources.mak)

* Update to link with the .la file in other Makefile.am files, and make a link to the
.a file for the convenience of other Makefiles which have not yet been converted to automake

v2: Remove stray -static from LDFLAGS
v3: Remove .a compatibility link on clean

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Matt Turner <mattst88@gmail.com>
ests/Makefile.am
68e04cc6014bf7a2c9bd0b3b783b4ec12aa2e824 29-Jun-2012 Jon TURNEY <jon.turney@dronecode.org.uk> automake: convert libglsl

v2: Use AM_V_GEN to silence generated code rules. Add BUILT_SOURCES to CLEANFILES
v3:
- Fix an accidental // in a path
- Use automake make rules for lex/yacc rather than writing our own
- Update .gitignore appropriately
- Build a libglcpp convenience library rather than awkwardly including
the files in libglsl and delegating the generation
- Remove libglsl.a compatibility link on clean
v4:
- Automake's rules for lex/yacc make .cc if source is .ll or .yy, and apparently we
must use those extensions "because of scons", so update everywhere glsl_parser.cpp
-> glsl_parser.cc and glsl_lexer.cpp -> glsl_lexer.cc. This fixes 'make tarballs'
and building with dricore enabled.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Matt Turner <mattst88@gmail.com>
gitignore
akefile
akefile.am
akefile.sources
lcpp/.gitignore
lcpp/Makefile.am
ests/Makefile.am
d9da350a8334201400a43d105b92fce2bd6a5f32 10-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/ir_builder: Add a new swizzle_for_size() function.

This swizzles away unwanted components, while preserving the order of
the ones that remain.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_builder.cpp
r_builder.h
0bb3d4ba54f98f4d45abe598dabc905f08055cd5 09-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/ir_builder: Add a generic constructor for unary expressions.

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 <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_builder.cpp
r_builder.h
b656df990f8c1d7468e11afa2079511d8b1febf4 09-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Initialize coordinate to NULL in ir_texture constructor.

I ran into this while trying to create a TXS query, which doesn't have a
coordinate. Since it didn't get initialized to NULL, a bunch of
visitors tried to access it and crashed.

Most of the time, this won't be a problem, but it's just a good idea.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.h
21cb5ed20d1d7984b7695395327ed0ba0b0d16e2 18-Dec-2011 Marek Olšák <maraeo@gmail.com> glsl: implement ARB_transform_feedback3 in the linker

Acked-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
2d03f48a65a666ecdcfaffa3d39ad1b77f2b25b6 18-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Add parsing for GLSL uniform blocks.

This doesn't do anything with the uniform block declarations yet, so
usage of those uniforms finds them to be undeclared.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st.h
st_to_hir.cpp
lsl_lexer.ll
lsl_parser.yy
912a429bc529a017a426f06631b31da1c0eaa3ae 26-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Don't hide the type of struct_declaration_list.

I've been trying to derive from this for UBO support, and the slightly
obfuscated types were putting me over the edge.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st.h
lsl_parser.yy
lsl_parser_extras.cpp
532e99cbf26d175220eac245b12011939ea07d0c 04-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add built-in #define for GL_ARB_uniform_buffer_object.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
lcpp/glcpp-parse.y
7fabb2b5939c8640075136fec15d6b87bad9c9dd 25-Dec-2011 Vincent Lejeune <vljn@ovi.com> glsl: Parser handles "#extension GL_ARB_uniform_buffer_object"

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.cpp
lsl_parser_extras.h
f4fb6bf08811cc69c1e635cf0af198ded197bcb0 24-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Reduce a bit of extra code in the merging of layout qualifiers.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
60a784d56e0034d32b9c243afd860cf095d3d2c5 24-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Take advantage of the layout qualifier flags union to clean up parsing.

The got_one variable was set iff one of the bits in flags.i was set.

v2: Fix incorrect dropping of the ARB_conservative_depth warning.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
1853f467c6c0a6e7636b40fe99e1195c43b847aa 02-Jul-2012 Brian Paul <brianp@vmware.com> glsl: fix unop/binop errors in comments
ower_instructions.cpp
b1802a2115323233352da558430e109ff187b8af 02-Jul-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused ir_loop_jump::loop pointer.

Commit 0c005bd7 intended to make ir_loop_jump::mode public, but also
accidentally added a new pointer to the enclosing loop. Furthermore, it
tried to initialize the new field by adding "this->loop = loop;" to the
constructor, but since there is no loop parameter, this only initialized
the field to itself---so it will likely be a garbage pointer.

A lot of code, such as lower_jumps, allocates new loop jumps without
setting this field appropriately, so any uses would probably just crash.

Thankfully, there were none, so we can just delete the field.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51574
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.h
8fb1e4a4628caee9e80dcbc47f8f9c772db09419 26-Jun-2012 Brian Paul <brianp@vmware.com> glsl: be more careful about counting varying vars in the linker

Previously, we were counting gl_FrontFacing, gl_FragCoord and gl_PointCoord
against the limit of varying variables. This prevented some valid shaders
from linking.

The other potential solution to this is to have the driver advertise
more varying vars or set the GLSLSkipStrictMaxVaryingLimitCheck flag.
But the above-mentioned variables aren't conventional varying attributes
so it doesn't seem right to count them.

Reviewed-by: Eric Anholt <eric@anholt.net>
inker.cpp
d8e61f8f86bfb078a35222f95ad4b0b4e6283f53 10-Jun-2012 Carl Worth <cworth@cworth.org> glsl: glcpp: Extend testing of #line directives

The most recent commit adds support for comments and macro expansion
on #line directives. Add testing to verify the new features.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/tests/091-hash-line.c
lcpp/tests/091-hash-line.c.expected
aac78ce8234d96932c38b3f48b1d828077bc0027 10-Jun-2012 Carl Worth <cworth@cworth.org> glsl: glcpp: Move handling of #line directives from lexer to parser.

The GLSL specification requires that #line directives be interpreted
after macro expansion. Our existing implementation of #line macros in
the lexer prevents conformance on this point.

Moving the handling of #line from the lexer to the parser gives us the
macro expansion we need. An additional benefit is that the
preprocessor also now supports comments on the same line as #line
directives.

Finally, the preprocessor now emits the (fully-macro-expanded) #line
directives into the output. This allows the full GLSL compiler to also
see and interpret these directives so it can also generate correct
line numbers in error messages.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/glcpp-lex.l
lcpp/glcpp-parse.y
lcpp/glcpp.h
lcpp/tests/091-hash-line.c.expected
39f8c46eaa4d1c3b072cd97d256fe973c1791b14 10-Jun-2012 Carl Worth <cworth@cworth.org> glsl: glcpp: Rename and document _glcpp_parser_expand_if

This function is currently used only in the expansion of #if lines,
but we will soon be using it more generally (for the expansion of
(_glcpp_parser_expand_and_lex_from) and some more documentation.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/glcpp-parse.y
1db463ce2e2812c4e41ab4096ff16a148d4bcc90 09-Jun-2012 Carl Worth <cworth@cworth.org> glsl: Consistently use length-based ralloc string functions for info_log.

Commit b823b99ec0f13af257dcd885f436a4d294c6222a switched from using
functions such as ralloc_asprintf and ralloc_strcat to
ralloc_asprintf_rewrite_tail. This change maintains the string's
length as a aparamter that is updated by the ralloc functions (rather
than recomputing it with strlen over and over).

However, the change failed to updated two locations (glcpp_error and
glcpp_warning), with the result that the string's length wasn't
updated by these calls. Then, subsequent calls to other
ralloc_asprintf_rewrite_tail would overwrite the text appended by
glcpp_error.

This commit fixes the two missing updates, and restores line numbers
to the output of glcpp error messages, (as noticed by a glcpp unit
test case that has been failing since the above-mentioned commit).

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/pp.c
c96b8302a398a6db27f1bb6070cdc088c7ee0fba 09-Jun-2012 Carl Worth <cworth@cworth.org> glsl: glcpp: Allow "#if undefined-macro' to evaluate to false.

A strict reading of the GLSL specification would have this be an
error, but we've received reports from users who expect the
preprocessor to interepret undefined macros as 0. This is the standard
behavior of the rpeprocessor for C, and according to these user
reports is also the behavior of other OpenGL implementations.

So here's one of those cases where we can make our users happier by
ignoring the specification. And it's hard to imagine users who really,
really want to see an error for this case.

The two affected tests cases are updated to reflect the new behavior.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/glcpp-parse.y
lcpp/tests/070-undefined-macro-in-expression.c
lcpp/tests/070-undefined-macro-in-expression.c.expected
lcpp/tests/098-elif-undefined.c
lcpp/tests/098-elif-undefined.c.expected
36b3ee2ffca2f260c9e5eb248b6e2b4ca2bf6fb1 26-Jun-2012 Brian Paul <brianp@vmware.com> glsl: fix comment typo
r.h
bebb0438113efdcc1c2aaed95c70ba87de1d3053 18-Jun-2012 Paul Berry <stereotype441@gmail.com> glsl: Add IsCentroid bitfield to gl_fragment_program.

This bitfield tells the back-ends which of a fragment shader's inputs
require centroid interpolation. It is only set for GLSL fragment
shaders, since assembly fragment shaders don't support centroid
interpolation.

Reviewed-by: Eric Anholt <eric@anholt.net>
r_set_program_inouts.cpp
37d699a296ac1d63b9276224847df4b645b53fe2 19-Jun-2012 Vinson Lee <vlee@freedesktop.org> scons: Add glsl/glcpp to the include path.

Fixes this build failure on Solaris.

Compiling build/sunos-debug/glsl/glcpp/glcpp-lex.c ...
"src/glsl/glcpp/glcpp-lex.l", line 30: cannot find include file: "glcpp-parse.h"

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Conscript
f2f05e50b1e88b431cb98348bf67e6d5a35d8cf1 20-Jun-2012 Paul Berry <stereotype441@gmail.com> glx/tests: Fix signed/unsigned comparison warnings.
ests/uniform_initializer_utils.cpp
4d9c3cbce9e1ff45e5a90dda4de4934599b88037 14-Jun-2012 Paul Berry <stereotype441@gmail.com> glsl: Use ir_unop_f2u to convert floats to uints.

Fixes piglit tests
spec/glsl-1.30/execution/{vs,fs}-float-uint-conversion on i965.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_function.cpp
613a8170ae53091d516f602d091a6bbcd169e92f 14-Jun-2012 Paul Berry <stereotype441@gmail.com> glsl: Add support for ir_unop_f2u to constant folding.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_constant_expression.cpp
8e31f961e6cfd9680b33647c053b0f708abb8a18 14-Jun-2012 Paul Berry <stereotype441@gmail.com> glsl: Add unary operation ir_unop_f2u.

Previously, we performed conversions from float->uint by a two step
process: float->int->uint. However, on platforms that use saturating
conversions (e.g. i965), this didn't work, because if the source value
was larger than the maximum representable int (0x7fffffff), then
converting it to an int would clamp it to 0x7fffffff.

This patch just adds the new opcode; further patches will adapt
optimization passes and back-ends to use it, and then finally the
ast_to_hir logic will be modified to emit the new opcode.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
r.h
r_validate.cpp
4bfdc8313592ec8a8794d6b7bc33a5c44df34ed4 04-Jun-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix pi/2 constant in acos built-in function

In single precision, 1.5707963 becomes 1.5707962513 which is too
small. However, 1.5707964 becomes 1.5707963705 which is just right.
The value 1.5707964 is already used in asin.ir.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
uiltins/ir/acos.ir
ae419a0159eeba6138d8c72a54737190cb6b1626 05-Jun-2012 Matt Turner <mattst88@gmail.com> glsl: Transform dot product by a basis vector into a swizzle

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ODO
pt_algebraic.cpp
9aa3fbcc2e1f46416f1d334427ebe48388584384 04-Jun-2012 Matt Turner <mattst88@gmail.com> glsl: Add is_basis function

Determines whether it's a basis vector, i.e., a vector with one element
equal to 1 and all other elements equal to 0.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
r.h
d7bef19c7ff40f0b83a42fdb8509eed3ad1e40a3 04-Jun-2012 Matt Turner <mattst88@gmail.com> glsl: Check for zero vectors in ir_binop_dot

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_algebraic.cpp
ea606ee7b49d130fdedd5a707e79fc9e37ba280c 11-Jun-2012 José Fonseca <jfonseca@vmware.com> scons: Fix scons build.
akefile.sources
337d9c955b070224f7278524af54ddacd8bb0f17 30-May-2012 Eric Anholt <eric@anholt.net> glsl: Put a bunch of optimization visitors under anonymous namespaces.

Because these classes are used entirely from their own source files
and not from separate DSOs, the linker gets to produce massively less
code. This cuts about 13k of text in the libdricore case. In the
non-libdricore case, the additional linkage information allows the
compiler to inline some code, so libglsl.a size actually increases by
about 300 bytes.

For a dricore build, improves shader_runner runtime on
glsl-fs-copy-propagation-texcoords-1 by 0.21% +/- 0.03% (n=353574,
outliers removed). No statistically significant difference with n=322
on glslparsertest on a yofrankie shader intended to test compiler
performance.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_algebraic.cpp
pt_constant_folding.cpp
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_copy_propagation.cpp
pt_copy_propagation_elements.cpp
pt_dead_code_local.cpp
pt_dead_functions.cpp
pt_function_inlining.cpp
pt_if_simplification.cpp
pt_noop_swizzle.cpp
pt_redundant_jumps.cpp
pt_structure_splitting.cpp
pt_swizzle_swizzle.cpp
pt_tree_grafting.cpp
279efce8bb7b6c802eb6c1de46971153ff6fdedb 29-May-2012 Eric Anholt <eric@anholt.net> automake: Merge the dricore libglsl build into libdricore.

Now we have just one library of "all of Mesa core" instead of both
libdricore and libglsl that drivers link against.

I did this change in a sort of nonrecursive make fashion: the
generated files are still produced in the non-automake build, like the
rest of dricore, but the GLSL files are stuffed into libdricore
without building a convenience library in src/glsl (even though we
could now). This would make a bit more sense if glsl was just another
dir under src/mesa, because right now I had to contort the prefix
variable name to look another ../ level up.
akefile
446faee094ae6f0a4914b59a9eb87077a1f7b3c5 29-May-2012 Eric Anholt <eric@anholt.net> automake: Add a prefix variable for libglsl sources.

See e86c40a84d241b954594f5ae7df9b9c3fc797a4e for reasoning. In the
process I did s/:=/=/ to shut up automake about nonportable make syntax.
ndroid.mk
akefile
akefile.sources
a018747ac8230f0dfb9f5f49a44d78fe97df84a0 15-May-2012 Eric Anholt <eric@anholt.net> glsl: Clean up warnings about deleting classes without virtual destructors.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.h
ea055e19c2757dfe97dd13c1deee2bfa177eae3f 05-Jun-2012 Marcin Slusarz <marcin.slusarz@gmail.com> glsl: fix deref_hash memory leak in constant_expression_value

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_constant_expression.cpp
ca9977d5c6f8e6ff8290bdf094d978487519d6f5 08-Jun-2012 Andreas Boll <andreas.boll.dev@gmail.com> glcpp: .gitignore cleanup

*.o, *.lo and *~ are already in toplevel .gitignore

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/.gitignore
abe976755318fa9dd88a5c48289623ab7c12ce02 08-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Bitwise conversion operator support in ir_constant_expression.

A "test_out = floatBitsToUint(-1.0);" fired through the GLSL compiler
gives a correct "(assign (x) (var_ref test_out)
(constant uint (3212836864)))"

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_constant_expression.cpp
1b8a3aad09d67e72903fdcc79beadfc3c77cae62 08-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Bitwise conversion operator support in ir_validate.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_validate.cpp
4fab1505594acf0cc02a53d01ce20c8b17e3e913 08-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Bitwise conversion operator support in ir_expression.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
500dcbb1aa991d4c92200fcacd6eb288bb2638d7 08-May-2012 Olivier Galibert <galibert@pobox.com> glsl: New unary opcodes for ARB_shader_bit_encoding support.

The opcodes are bitcast_f2u, bitcast_f2i, bitcast_i2f and bitcast_u2f.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/ir/floatBitsToInt.ir
uiltins/ir/floatBitsToUint.ir
uiltins/ir/intBitsToFloat.ir
uiltins/ir/uintBitsToFloat.ir
uiltins/profiles/ARB_shader_bit_encoding.glsl
r.cpp
r.h
199771bc325900eb1d3acc7fa03808894a94fdb2 30-Apr-2012 Olivier Galibert <galibert@pobox.com> glsl: Scaffolding for ARB_shader_bit_encoding.

That adds support for activating the extension. It doesn't actually
*do* anything yet, of course.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/tools/generate_builtins.py
lcpp/glcpp-parse.y
lsl_parser_extras.cpp
lsl_parser_extras.h
tandalone_scaffolding.cpp
3603fdcebfa25e2217f1dbfb0a99261be3e84b02 06-Jun-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Hook up loop_variable_state destructor to plug a memory leak.

While ~loop_state() is already freeing the loop_variable_state objects
via ralloc_free(this->mem_ctx), the ~loop_variable_state() destructor
was never getting called, so the hash table inside loop_variable_state
was never getting destroyed.

Fixes a memory leak in any shader with loops.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
oop_analysis.h
25edfbfccfb8af9eecd949c3fc4f2680c5b963b6 01-Jun-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Fix textureGrad() for Array samplers.

We were incorrectly assuming that the coordinate's dimensionality is
equal to the gradient's dimensionality. For array types, the coordinate
has one more component.

Fixes 12 subcases of oglconform's glsl-bif-tex-grad test.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/tools/texture_builtins.py
555e00fdc30514b45e9afae18f56a9a4bc65f364 05-Jun-2012 Paul Berry <stereotype441@gmail.com> Fix .gitignore for ralloc-test

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ests/.gitignore
adfe53184155f33958f82383a7148b0536455a4c 19-May-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Remove spurious printf messages

These look like debug messages from the switch-statement development.

NOTE: This is a candidate for the 8.0 release branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
151bf6e6cf8f9de4067cfcf15f6ac448ff295533 29-May-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/tests: Plumb $(PYTHON2) and $(PYTHON_FLAGS) into optimization-test.

Some distributions (like Arch Linux) make /usr/bin/python Python 3,
rather than Python 2. Since compare_ir uses /usr/bin/env python,
such systems will fail to run optimization-test, causing 'make check' to
always fail.

Automake's TESTS_ENVIRONMENT variable provides a mechanism to run
programs or set environment variables in the test environment.
Ideally, I think we would want to use AM_TESTS_ENVIRONMENT, since
TESTS_ENVIRONMENT is supposed to be user-overridable. However, it isn't
supported using the default/serial test runner.

Fixes 'make check' on Arch Linux and Gentoo.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Matt Turner <mattst88@gmail.com>
ests/Makefile.am
ests/optimization-test
a44ccdc8760fdbd5ba5c01ffff3809fbfb364934 22-May-2012 Kenneth Graunke <kenneth@whitecape.org> ralloc: Add some basic unit tests.

I started writing unit tests for a new piece of code, and discovered
they all failed due to a bug in ralloc. Clearly it needs a test suite.

v2: Rename to 'ralloc-test' and fix copyright date. (idr review)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
ests/.gitignore
ests/Makefile.am
ests/ralloc_test.cpp
1559b2e2d7c0d9ddab0e186fcf855ea847152ef1 22-May-2012 Kenneth Graunke <kenneth@whitecape.org> ralloc: Fix ralloc_parent() of memory allocated out of the NULL context.

If an object is allocated out of the NULL context, info->parent will be
NULL. Using the PTR_FROM_HEADER macro would be incorrect: it would say
that ralloc_parent(ralloc_context(NULL)) == sizeof(ralloc_header).

Fixes the new "null_parent" unit test.

NOTE: This is a candidate for the 7.9, 7.10, 7.11, and 8.0 branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
alloc.c
9f6932cb83def5449a9293cb41238bbc492cb8c4 23-May-2012 Paul Berry <stereotype441@gmail.com> glsl/tests: Add .gitignore for uniform initialization unit test.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
ests/.gitignore
aa173e16a07566b7549b00946840ea16ac17a380 19-May-2012 Paul Berry <stereotype441@gmail.com> glsl/constant propagation: kill whole var if LHS involves array indexing.

When considering which components of a variable were killed by an
assignment, constant propagation would previously just use the write
mask of the assignment. This worked if the LHS of the assignment was
simple, e.g.:

v.xy = ...; // (assign (xy) (var_ref v) ...)

But it did the wrong thing if the LHS of the assignment involved an
array indexing operator, since in this case the write mask is always
(x):

v[i] = ...; // (assign (x) (deref_array (var_ref v) (var_ref i)) ...)

In general, we can't predict which vector component will be selected
by array indexing, so the only safe thing to do in this case is to
kill the entire variable.

Fixes piglit tests {fs,vs}-vector-indexing-kills-all-channels.shader_test.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
pt_constant_propagation.cpp
b45052b3f761deb980bcca405f25e543892a93ee 13-Apr-2012 Ian Romanick <ian.d.romanick@intel.com> glsl/tests: Add test for uniform initialization by the linker

v2: Put unit tests in src/glsl/tests rather than tests/glsl.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
ests/Makefile.am
ests/copy_constant_to_storage_tests.cpp
ests/set_uniform_initializer_tests.cpp
ests/uniform_initializer_utils.cpp
ests/uniform_initializer_utils.h
76027f5b5cd8017f8455e2df375fcea7cc888dce 10-Apr-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Propagate sampler uniform initializers to gl_shader_program::SamplerUnits

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniform_initializers.cpp
b610881317a7775a7ffe5f032099d8b2dc45eff0 10-Apr-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Initialize samplers to 0, propagate sampler values to the gl_program

The spec requires that samplers be initialized to 0. Since this
differs from the 1-to-1 mapping of samplers to texture units assumed
by ARB assembly shaders (and the gl_program structure), be sure to
propagate this date from the gl_shader_program to the gl_program.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
CC: Vadim Girlin <vadimgirlin@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49088
ink_uniforms.cpp
a2e623054b5d8eafebc7499efe93e4bceae16ead 06-Apr-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Set initial values for uniforms in the linker

v2: Fix handling of arrays-of-structure. Thanks to Eric Anholt for
pointing this out.

v3: Minor comment change based on feedback from Ken.

Fixes piglit glsl-1.20/execution/uniform-initializer/fs-structure-array
and glsl-1.20/execution/uniform-initializer/vs-structure-array.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
akefile.sources
ink_uniform_initializers.cpp
ink_uniforms.cpp
inker.h
aa5ec137757323b424d0f2638c50c93b9b06ffff 14-May-2012 Eric Anholt <eric@anholt.net> glsl: Drop the extra NULL specifiction on ir_assignment constructors.

It's an implied argument, and I don't think being explicit about it
helps.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
9c4e9ce051bb43861adb4f8cd8e88a733c2f3ed1 14-May-2012 Eric Anholt <eric@anholt.net> glsl: Fix assertion failure on handling switch on uint expressions.

Fixes piglit glsl-1.30/execution/switch/fs-uint.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
bbbc7c7d566905920967f56648fc26abcb37f4a1 14-May-2012 Eric Anholt <eric@anholt.net> glsl: Reject non-scalar switch expressions.

The comment quotes spec saying that only scalar integers are allowed,
but we only checked for integer.

Fixes piglit switch-expression-const-ivec2.vert

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
5d6ea16dfe99e1aba61c25a897b66951faab1a39 14-May-2012 Eric Anholt <eric@anholt.net> glsl: Let the constructor figure out the types of switch-related expressions.

I noticed this while unindenting the code.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
5462f3679ab7217d3a3be48365750801c7771237 14-May-2012 Eric Anholt <eric@anholt.net> glsl: Fix indentation of switch code.

I managed to completely trash it in 22d81f15.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
05c200bac049ed4760f0af6786e463e2520b9c9c 23-Feb-2012 Eric Anholt <eric@anholt.net> glsl: Improve the local dead code optimization to eliminate unused channels.

Total instructions: 261582 -> 261316
135/2147 programs affected (6.3%)
36752 -> 36486 instructions in affected programs (0.7% reduction)

This excludes a tropics shader that now gets 16-wide mode and throws
off the numbers. 5 shaders are hurt: two extra MOVs in 4 tropics
shaders it looks like because we don't split register names according
to independent webs, and one gstreamer shader where it looks like
try_rewrite_rhs_to_dst() is falling on its face.

This should also help avoid a regression in VSes from idr's ARB
programs to GLSL work.
pt_dead_code_local.cpp
e88f9b9546119db83e19b1bdd2bc9db45058cebd 15-May-2012 José Fonseca <jfonseca@vmware.com> glsl: Fix lower_discard_flow prototype mismatch.

Should fix MSVC link failure.
r_optimization.h
3de1395fa5a563c13774ac1c38722c16cecc521d 04-May-2012 Eric Anholt <eric@anholt.net> glsl: Implement the GLSL 1.30+ discard control flow rule in GLSL IR.

Previously, I tried implementing this in the i965 driver, but did so
in a way that violated the intent of the spec, and broke Tropics.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
akefile.sources
r_optimization.h
inker.cpp
ower_discard_flow.cpp
e21b9f1f19d2345026a7fbe095a776d0b64557ec 04-May-2012 Eric Anholt <eric@anholt.net> glsl: Remove the opt_discard_simplification pass.

This conflicts with the GLSL 1.30+ rules for derivatives after a
discard has occurred.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
akefile.sources
lsl_parser_extras.cpp
pt_discard_simplification.cpp
est_optpass.cpp
363c14ae0cd2baa624d85e8c9db12cd1677190ea 02-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Change built-in constant expression evaluation to run the IR.

This removes code duplication with
ir_expression::constant_expression_value and builtins/ir/*.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.h
r_constant_expression.cpp
2ff7b121cad2892698ff1aa7690dd361ea2739a7 02-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Add an origin pointer in the function signature object.

This points to the object with the function body, allowing us to map
from a built-in prototype to the actual body with IR code to execute.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
r.h
r_clone.cpp
8ec01ba2ff95449674c779c05afcd32bbf7dbdc8 02-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Add methods to copy parts of one ir_constant into another.

- copy_masked_offset copies part of a constant into another,
assign-like.

- copy_offset copies a constant into (a subset of) another,
funcall-return like.

These methods are to be used to trace through assignments and function
calls when computing a constant expression.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
r.cpp
r.h
a270e86d382597d4d01ebcfa1693e21d778cbe6d 02-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Add a constant_referenced method to ir_dereference*

The method is used to get a reference to an ir_constant * within the
context of evaluating an assignment when calculating a
constant_expression_value.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
r.h
r_constant_expression.cpp
6e4852a3a5f3cbe52c53d91d343a37861f207563 02-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Add a variable context to constant_expression_value().

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
st_function.cpp
r.h
r_constant_expression.cpp
27a198388ed78c83d9a255efc0fb2294d985f3ad 02-May-2012 Olivier Galibert <galibert@pobox.com> glsl: Extend ir_constant::zero to handle more types.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
r.cpp
f72e9b2041e294c8ac2258ff3f2b923c39cbef83 08-May-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix broken constant expression handling for <, <=, >, and >=.

We were looping over all the vector components, but only dealing with
the first one. This was masked by the fact that constant expression
handling on built-ins went through custom code for the lessThan()
/function/ rather than the ir_binop_less expression operator.

NOTE: This is a candidate for all release branches.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Olivier Galibert <galibert@pobox.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
r_constant_expression.cpp
4595288ba844def45cc858fab44fad3efa1ab4c8 24-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Fix regression in function out-parameter lvalue detection.

When doing the var->assigned change in
f2475ca424f7e001be50f64dafa5700f6603d684, I overzealously indented the
second block of code into the "if (var)" test. Revert these blocks to
the way they were before, just taking advantage of "var" to avoid
re-calling variable_referenced().

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49066
st_function.cpp
b2ee5a08bae6cdbbdafc1f1d9d6f3afbad2f7944 24-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Don't consider unused FS out variables as being statically assigned.

I only considered var->assigned for FragColor and FragData, but
ignored when it was false for out vars. Fixes piglit
write-gl_FragColor-and-not-user-output.frag

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49068
st_to_hir.cpp
6508b0b9b0981662b9ae5bc559b4a6be524f7b86 25-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Always copy the index when cloning a variable.

The index is also used for GL_ARB_blend_func_extended. Cloning in
i965 was dropping a non-ARB_explicit_attrib_location index.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
r_clone.cpp
d5a10dba6464d6cc40b3abcd6b704fb087e1056c 02-Apr-2012 Dylan Noblesmith <nobled@dreamwidth.org> glsl: report errors via GL_ARB_debug_output

Reviewed-by: Brian Paul <brianp@vmware.com>
lsl_parser_extras.cpp
tandalone_scaffolding.cpp
tandalone_scaffolding.h
8c99906cf5c8825ada0699f61926864e568ca69a 02-Apr-2012 Dylan Noblesmith <nobled@dreamwidth.org> glsl: add gl_context member

Reviewed-by: Brian Paul <brianp@vmware.com>
lsl_parser_extras.cpp
lsl_parser_extras.h
48e8a010aebbb40c75698e2aa8854d129c89f359 02-Apr-2012 Dylan Noblesmith <nobled@dreamwidth.org> glsl: consolidate error/warning code

And lay the groundwork for GL_ARB_debug_output.

v2: Add descriptive comments.

Reviewed-by: Brian Paul <brianp@vmware.com>
lsl_parser_extras.cpp
b389b608d8d853c1f9383b04a222d96a5a096178 01-May-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove some completed tasks from the old "TODO" file.
ODO
2d75a1e25e6ddcd65964d30fc3c782df2e880cc4 30-Apr-2012 Vinson Lee <vlee@freedesktop.org> glsl: Initialize member variable in ir_copy_propagation_elements_visitor.

Fix uninitialized scalar field defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
pt_copy_propagation_elements.cpp
e372aa69494469d6c43c315b5c39355dece65dcf 27-Apr-2012 Vinson Lee <vlee@freedesktop.org> glsl: Remove unused member predicate from ir_dead_functions_visitor.

Fix uninitialized pointer field defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
pt_dead_functions.cpp
6af4c9006cddaf5b2c6ae39b9e5722d93e2ad44d 26-Apr-2012 Vinson Lee <vlee@freedesktop.org> glsl: Remove unused member mem_ctx from ir_dead_functions_visitor.

Fix uninitialized pointer field defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_structure_splitting.cpp
e9df9636b986b09ba37095d963b388571f528e1b 18-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Add implementation of inverse() for mat2/3/4.

This is taken from the ogl-math project, with Inverse renamed to adj
(since it's not actually the inverse), transposed, and our types
plugged in. There are potential CSE opportunities in this code
(particularly for hardware with RCP but not DIV), but we should be
doing CSE anyway, so don't hand-optimize.

Fixes piglit inverse tests.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
uiltins/glsl/inverse.glsl
uiltins/profiles/140.glsl
7de1331662816d31fb9bed423b1e5372284a260e 18-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Add support for generating builtin code from GLSL instead of IR.

This takes advantage of the builtin compiler to generate IR into a
string, the same way we read GLSL for function prototypes for our
profiles.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/tools/generate_builtins.py
41b47441d720957d7b8a63afa26d94c752c8740b 18-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Make ir_reader parse the "temporary" variable qualifier.

This lets ir_reader eat the output of builtin_compiler on actual
function definitions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_reader.cpp
6a6cb03507da75a30224020c9193464ca5b81c5f 18-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Add doxygen explaining what main.cpp is for.

I keep getting lost in the Makefile trying to figure out what to edit
to work on builtin_compiler or glsl_compiler.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ain.cpp
4b2a4cb7c2131c3c31e3d44a0d8838ef45f270e7 30-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Properly throw compile-time errors for conflicting FS output writes.

We were checking for these at link time previously, which is not as
early as mandated, and would actually fail to detect conflicting
writes if dead code removal removed some writes.

Fixes failures in piglit
glsl-*/compiler/fragment-outputs/write-gl_Frag*

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
f2475ca424f7e001be50f64dafa5700f6603d684 30-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Track in each ir_variable whether it was ever assigned.

This will be used for some compile-and-link-time error checking, where
currently we've been doing error checking only at link time.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_function.cpp
st_to_hir.cpp
r.h
cc7e0de009a0ab528fe950b17fa465a0a97988fc 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Convert the tests directory to automake.

This runs optimization-test and produces the usual automake test
output, which may be interesting to automated build systems.

This doesn't convert the tests to be individually exposed to the
automake runner, because automake doesn't like wildcards (due to being
nonportable in make, not that we care).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ests/.gitignore
ests/Makefile.am
86f270e0a9d34dd2b6689b7f7c693620db65098c 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Fix up some comments in structure splitting, based on array-split work.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_structure_splitting.cpp
6de5da079682efd3f8887d3e0a7add7e70a5433d 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Don't allow array splitting on function arguments.

This is the reason the declaration member existed in the reference
visitor, but I didn't copy the code from structure splitting that
avoided setting it.

This wasn't currently a problem, because we don't allow splitting of
in/out variables. But that would be nice to change some day.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_array_splitting.cpp
538ba0a36373d7d0bd047e6fc4ef4e6e8d8bb8d7 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Rename the "whole_array_access" member in array splitting.

This was carried over from structure splitting, without thinking about
whether the name still made sense in this context.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_array_splitting.cpp
36a8c9caafef79524920120286649a0f53fe5228 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Fix up a comment explaining what a visitor class does.

Ken noted that some of the "actual work" was happening in the caller
of this class.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_array_splitting.cpp
c07290ddb2bf3095b9f5a1e0b33697999834fa0e 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Use the column_types() helper method.

Ken noted this in a review of this patch that I pushed early.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_array_splitting.cpp
14e9942841d638b0ce5e858540f786fa4b04f67d 19-Apr-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused mem_ctx field from ir_array_splitting_visitor.

Vinson reported that we failed to initialize this, which would lead to
all kinds of crashes if we actually used it. Since we don't use it,
we may as well just delete the broken code.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
pt_array_splitting.cpp
32f7676e9c09d9c13da3fa2518807ab94aad5fb2 16-Apr-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Rework profiles to use the new '.glsl' common suffix.

Deletes a lot of pointless duplication, as well as some run-time effort.

Conveniently, GLSL 1.40 no longer needs a .vert variant, since it
doesn't define any built-ins specific to the vertex shader stage.

ARB_texture_rectangle and OES_EGL_image_external also only need a single
profile, since the .vert and .frag variants were identical.

I didn't bother with EXT_texture_array and OES_texture_3D because
they're so tiny that the savings would be miniscule.

Cuts the generated builtin_function.cpp from 1.7MB to 1.0MB (41%).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/profiles/100.frag
uiltins/profiles/100.glsl
uiltins/profiles/100.vert
uiltins/profiles/110.frag
uiltins/profiles/110.glsl
uiltins/profiles/110.vert
uiltins/profiles/120.frag
uiltins/profiles/120.glsl
uiltins/profiles/120.vert
uiltins/profiles/130.frag
uiltins/profiles/130.glsl
uiltins/profiles/130.vert
uiltins/profiles/140.frag
uiltins/profiles/140.glsl
uiltins/profiles/140.vert
uiltins/profiles/ARB_shader_texture_lod.frag
uiltins/profiles/ARB_shader_texture_lod.glsl
uiltins/profiles/ARB_shader_texture_lod.vert
uiltins/profiles/ARB_texture_rectangle.frag
uiltins/profiles/ARB_texture_rectangle.glsl
uiltins/profiles/ARB_texture_rectangle.vert
uiltins/profiles/OES_EGL_image_external.frag
uiltins/profiles/OES_EGL_image_external.glsl
uiltins/profiles/OES_EGL_image_external.vert
fbea94ae59817c1d9db9b2f1e257daeadf7c15a9 17-Apr-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Support stage-agnostic built-in profiles.

The built-in subsystem uses "profiles," or GLSL shaders containing
prototypes for all built-ins supported within a particular language
version (or extension) and shader stage.

Since profiles were stage-specific, we had to cut and paste almost all
the prototypes between (e.g.) 110.vert and 110.frag. Naturally, this
led to sundry cut and paste bugs, where someone fixed an issue in .frag
but neglected to update .vert, or vice-versa. Geometry shaders would
have only made this worse.

This patch introduces support for a new '.glsl' profile suffix which
contains prototypes common to all shader stages. The existing '.frag'
and '.vert' profiles need only contain the few stage-specific built-ins.

Not only does this remove duplication, it makes built-in setup slightly
faster: we don't need to re-read the common prototypes and function
bodies for both the vertex and fragment shader stage.

Internally, this was trivial. We already create a list of gl_shader
objects to search through for built-ins: one for the core language
version/stage, and additional shaders for any extensions in use. This
patch simply adds another shader to the list: core/common, core/stage,
and extensions.

The next patch will update the profiles to remove the duplication.
It's separated out purely to make review easier.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/tools/generate_builtins.py
7e35d97a02cf139746ce9e85b78fe0c651139074 16-Apr-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Make the standalone compiler accept '.glsl' files.

These ought to be treated as 'any stage', but for now, they're just
treated as vertex shaders.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
ain.cpp
f4f6e1f5a01ed4e4108dc0c4b94d24bb1d76347f 16-Apr-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Use ivec for texel offsets in textureProjGradOffset.

The GLSL 1.30 -> 4.10 specs all erroneously say "vec2" for a few
overloads of textureProjGradOffset, while most overloads and all other
texturing functions use ivec types.

The GLSL 4.20 specification corrects these to "ivec2", but doesn't
mention this as being a conscious change in behavior. Nor does the
ARB_shading_language_420pack extension. So presumably it was a typo.

At any rate, our builtin functions all use ivec already, so the fact
that these prototypes use plain vecs will only lead to applications
dying in a fire when trying to use them.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
uiltins/profiles/130.frag
uiltins/profiles/130.vert
uiltins/profiles/140.vert
35f2fb70d3826df70fa2f53af05339137cddefc8 16-Apr-2012 Eric Anholt <eric@anholt.net> Revert "glsl: Refuse to link GLSL 1.40+ shaders that would use fixed function."

This reverts commit 4ec449a6ed1d2cea3bf83d6518b3b352ce5daceb.

I meant to not push this one. Review found that a link error is not
mandated: it should link, but you get undefined rendering if you rely
on a missing stage.

page 42/55 section 2.11 "Vertex Shaders":

"If the program object has no vertex shader, or no program object
is currently in use, the results of vertex shader execution are
undefined."

(and similar for page 160/173 section 3.9 "Fragment Shaders" for FS,
and page 45/58 section 2.11.2 "Program Objects" for program being 0)

It turns out the commit was broken anyway, because it was missing a
"goto done", so linkstatus got smashed back to true later and the
error just showed up as a warning in the infolog.
inker.cpp
4ec449a6ed1d2cea3bf83d6518b3b352ce5daceb 13-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Refuse to link GLSL 1.40+ shaders that would use fixed function.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
acd4024e0a0096c351a7143f908e029df53b1fdf 14-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Add remaining *sampler2DRect* texture functions.

Fixes the new piglit texelFetch() tests on these. Note that the rest
of the new functions are not tested (same as the non-2DRect versions
of most of them).
uiltins/profiles/140.frag
uiltins/profiles/140.vert
uiltins/tools/texture_builtins.py
b9fed9f3d537f4f28ea19996fe34463d15831411 16-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Fix the prototype of textureProjGradOffset(sampler2DShadow)

Indirectly caught by Ken's review of my GLSL 1.40 changes where I
copy-and-pasted this line.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/140.frag
56e2f97697846c800b2ce53ad0bed87e3c1a5767 13-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Mark [iu]sampler{Buffer,2DRect}as reserved in GLSL 1.40.

The non-integer versions were already reserved in 1.30, but apparently
these were forgotten.

Fixes piglit glsl-1.40/compiler/reserved/

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_lexer.ll
lsl_parser.yy
d91c8edd851839799d8338ecc127ea004d76fcab 13-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Add textureSize(*samplerBuffer) support.

Fixes the corresponding new tests in piglit.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/140.frag
uiltins/profiles/140.vert
uiltins/tools/texture_builtins.py
9a01e09ee57a875ccff58316c81395c3f1094aa6 13-Apr-2012 Eric Anholt <eric@anholt.net> glsl: Fix comment typo in 1.40 work.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltin_types.h
3f349d4e18d8c114a34fc3c36e1dc55345c1cc31 16-Mar-2012 Eric Anholt <eric@anholt.net> glsl: If an "if" has no "then" or "else" code left, remove it.

Cuts 8/1068 instructions from glyphy's fragment shaders on i965.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
pt_if_simplification.cpp
8bb0091e6838aeee2a5819850c334fde71b5a439 20-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add a helper for generating temporary variables in ir_builder.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_builder.cpp
r_builder.h
d32780d5041a6d241834fe565739104f86300425 20-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add a helper for ir_builder to make dereferences for assignments.

v2: Fix writemask setup for non-vec4 assignments.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_builder.cpp
r_builder.h
7e88f8ce8f9d72bbda248554e0630b4aca7e1154 20-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Make a little tracking class for emitting IR lists.

This lets us significantly shorten p->instructions->push_tail(ir), and
will be used in a few more places.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_builder.cpp
r_builder.h
b782352745d322596a9122969f5c0e57ea032c1b 19-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add common swizzles to ir_builder.

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 <kenneth@whitecape.org>
r_builder.cpp
r_builder.h
d6e6566206029ace72ba037a3ef7950876eeb88b 19-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Let ir_builder expressions take un-dereferenced variables.

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 <kenneth@whitecape.org>
r_builder.cpp
r_builder.h
599aac95ff2149d881177ed75a48d97d3dcf47bd 19-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Create an ir_builder helper for hand-generating IR.

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 <kenneth@whitecape.org>
akefile.sources
r_builder.cpp
r_builder.h
1256a5dcc86014d48bdc6fd10ea5a2fa11241667 24-Mar-2012 Dave Airlie <airlied@redhat.com> glsl: add support for ARB_blend_func_extended (v3)

This adds index support to the GLSL compiler.

I'm not 100% sure of my approach here, esp without how output ordering
happens wrt location, index pairs, in the "mark" function.

Since current hw doesn't ever have a location > 0 with an index > 0,
we don't have to work out if the output ordering the hw requires is
location, index, location, index or location, location, index, index.
But we have no hw to know, so punt on it for now.

v2: index requires layout - catch and error
setup explicit index properly.

v3: drop idx_offset stuff, assume index follow location

Signed-off-by: Dave Airlie <airlied@redhat.com>
st.h
st_to_hir.cpp
uiltin_variables.cpp
lsl_parser.yy
r.h
r_clone.cpp
r_set_program_inouts.cpp
inker.cpp
f8cf79936b42405a8366613b80e3bde21aadaa02 24-Mar-2012 Dave Airlie <airlied@redhat.com> mesa: add support for ARB_blend_func_extended (v4)

Add implementations of the two API functions,
Add a new strings to uint mapping for index bindings
Add the blending mode validation for SRC1 + SRC_ALPHA_SATURATE
Add get for MAX_DUAL_SOURCE_DRAW_BUFFERS

v2:
Add check in valid_to_render to address case in spec ERRORS.

v3:
Add index to ir.h so this patch compiles on its own
fixup comment

v4: fixup Brian's comments

The GLSL patch will setup the indices.

Signed-off-by: Dave Airlie <airlied@redhat.com>
r.h
3bdccbc3e0185fbca16eada2a76f55c6e3f867b5 22-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Extend the array splitting optimization pass to matrices.

This should fit in well with our lower_mat_op_to_vec code: now, in
addition to having expressions on each column of a matrix, we also
split the columns to separate variables so they can be tracked
individually by the copy propagation, dead code, and other passes.

This optimizes out some more code generation in unigine and gstreamer
shaders.

Total instructions: 269342 -> 269270
14/2148 programs affected (0.7%)
2226 -> 2154 instructions in affected programs (3.2% reduction)
pt_array_splitting.cpp
60177d5e2aec07ed6386a6935b118a356d58c4ec 03-Oct-2010 Eric Anholt <eric@anholt.net> glsl: Add an array splitting pass.

I've had this code laying around almost done for a long time. The
idea is like opt_structure_splitting, that we've got a bunch of
transforms at the GLSL IR level that only understand scalars and
vectors, which just skip complicated dereferences. While driver
backends may manage some optimization after they split matrices up
themselves, it would be better to bring all of our optimization to
bear on the problem.

While I wasn't expecting changes quite yet, a few programs end up
winning: a gstreamer convolution shader, and the Humus dynamic
branching demo:
Total instructions: 269430 -> 269342
3/2148 programs affected (0.1%)
1498 -> 1410 instructions in affected programs (5.9% reduction)
akefile.sources
lsl_parser_extras.cpp
r_optimization.h
pt_array_splitting.cpp
fda662f4dffa658d28ea739dd236fe0350828d59 22-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Don't apply optimization passes to builtins.

The builtins we have are generally optimized, having been
hand-written. This avoids generating bad code when an optimization
pass prints debug output.
uiltins/tools/generate_builtins.py
4b06280ea34ce0e2ef9ec36df792c28c3828eabd 05-Apr-2012 Vadim Girlin <vadimgirlin@gmail.com> glsl: fix variable ordering in the output_read_remover

Use the hash of the variable name instead of the pointer value.

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
ower_output_reads.cpp
bb430ced7fb2aa26007637a0907d886716e8ddd6 26-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add texelFetch(*samplerBuffer) entrypoints to GLSL 1.40.

Fix texelFetch(sampler2DRect) and textureSize(samplerBuffer)
generation to not reference a LOD at the same time because it's easier
than not fixing it.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/140.frag
uiltins/profiles/140.vert
uiltins/tools/texture_builtins.py
659855252107debc47dbac8ec7985e1024d7ab5c 26-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add support for parsing [iu]samplerBuffer types in GLSL 1.40.

The samplerBuffer type will be undefined in !glsl 1.40, and the
keyword is marked as reserved. The [iu]samplerBuffer types are not
marked as reserved pre-1.40, so they don't have separate tokens and
fall through to normal type handling.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser.yy
lsl_types.cpp
eb7a71dea78152142b456f29e4881c4d3aeb56b6 30-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Drop the round-trip through ast_type_specifier for many builtin types.

We have lexer recognition of a bunch of our types based on the
handling. This code was mapping those recognized tokens to an enum
and then to a string of their name. Just drop the enums and provide
the string directly in the parser.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st.h
st_to_hir.cpp
st_type.cpp
lsl_parser.yy
b2c0df2b60a77b043d461f265c85d8b5b066a008 30-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Use (const char *) in AST nodes rather than plain (char *).

Nothing actually relied on them being mutable, and there was at least
one cast which discarded const qualifiers. The next patch would have
introduced many more.

Casting away const qualifiers should be avoided if at all possible.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st.h
lsl_parser.yy
lsl_parser_extras.cpp
f75c2d53146ea14f8dfedcc5b7a4704278ba0792 21-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Demote 'type' from ir_instruction to ir_rvalue and ir_variable.

Variables have types, expression trees have types, but statements don't.
Rather than have a nonsensical field that stays NULL in the base class,
just move it to where it makes sense.

Fix up a few places that lazily used ir_instruction even though they
actually knew the particular subclass.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_function.cpp
r.h
r_function.cpp
r_validate.cpp
ower_variable_index_to_cond_assign.cpp
82065fa20ee3f2880a070f1f4f75509b910cedde 21-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove ir_call::get_callee() and set_callee().

Previously, set_callee() performed some assertions about the type of the
ir_call; protecting the bare pointer ensured these checks would be run.

However, ir_call no longer has a type, so the getter and setter methods
don't actually do anything useful. Remove them in favor of accessing
callee directly, as is done with most other fields in our IR.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r.cpp
r.h
r_clone.cpp
r_function_can_inline.cpp
r_function_detect_recursion.cpp
r_validate.cpp
ink_functions.cpp
inker.cpp
ower_clip_distance.cpp
pt_constant_folding.cpp
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_copy_propagation.cpp
pt_copy_propagation_elements.cpp
pt_dead_functions.cpp
pt_tree_grafting.cpp
d884f60861f270cdcf7d9d47765efcf1e1de30b6 20-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Convert ir_call to be a statement rather than a value.

Aside from ir_call, our IR is cleanly split into two classes:
- Statements (typeless; used for side effects, control flow)
- Values (deeply nestable, pure, typed expression trees)

Unfortunately, ir_call confused all this:
- For void functions, we placed ir_call directly in the instruction
stream, treating it as an untyped statement. Yet, it was a subclass
of ir_rvalue, and no other ir_rvalue could be used in this way.
- For functions with a return value, ir_call could be placed in
arbitrary expression trees. While this fit naturally with the source
language, it meant that expressions might not be pure, making it
difficult to transform and optimize them. To combat this, we always
emitted ir_call directly in the RHS of an ir_assignment, only using
a temporary variable in expression trees. Many passes relied on this
assumption; the acos and atan built-ins violated it.

This patch makes ir_call a statement (ir_instruction) rather than a
value (ir_rvalue). Non-void calls now take a ir_dereference of a
variable, and store the return value there---effectively a call and
assignment rolled into one. They cannot be embedded in expressions.

All expression trees are now pure, without exception.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_function.cpp
uiltins/ir/acos.ir
uiltins/ir/atan.ir
r.cpp
r.h
r_basic_block.cpp
r_clone.cpp
r_constant_expression.cpp
r_expression_flattening.cpp
r_hv_accept.cpp
r_print_visitor.cpp
r_reader.cpp
r_validate.cpp
inker.cpp
pt_constant_folding.cpp
pt_constant_variable.cpp
pt_dead_code.cpp
pt_dead_code_local.cpp
pt_function_inlining.cpp
pt_tree_grafting.cpp
622eed075092a0325e0927bf2f9ef29f20bbf416 22-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Split out ir_reader's ability to read ir_dereference_variables.

Most of the time, we just want to read an ir_dereference, so there's no
need to have these in separate functions. However, the next patch will
want to read an ir_dereference_variable directly.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_reader.cpp
d0fa0cb52cebdcd0ca483b9cd7af6be2f228b8dc 20-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Move constant expression handling from calls to signatures.

When translating a call from AST to HIR, we need to decide whether it
can be evaluated to a constant before emitting any code (namely, the
temporary declaration, assignment, and call.)

Soon, ir_call will become a statement taking a dereference of where to
store the return value, rather than an rvalue to be used on the RHS of
an assignment. It will be more convenient to try evaluation before
creating a call. ir_function_signature seems like a reasonable place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r.h
r_constant_expression.cpp
807e967c615dc80a264af5a89af7649f95481744 23-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Use ir_rvalue to represent generic error_type values.

Currently, ir_call can be used as either a statement (for void
functions) or a value (for non-void functions). This is rather awkward,
as it's the only class that can be used in both forms.

A number of places use ir_call::get_error_instruction() to construct a
generic value of error_type. If ir_call is to become a statement, it
can no longer serve this purpose.

Unfortunately, none of our classes are particularly well suited for
this, and creating a new one would be rather aggrandizing. So, this
patch introduces ir_rvalue::error_value(), a static method that creates
an instance of the base class, ir_rvalue. This has the nice property
that you can't accidentally try and access uninitialized fields (as it
doesn't have any). The downside is that the base class is no longer
abstract.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_function.cpp
st_to_hir.cpp
ir_field_selection.cpp
r.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_hierarchical_visitor.cpp
r_hierarchical_visitor.h
r_hv_accept.cpp
r_print_visitor.cpp
r_print_visitor.h
r_visitor.h
ac0f8bae8d39ca9f5e873ba8411472e2962890cd 29-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Combine AST-level and IR-level parameter mode checking loops.

generate_call() and ast_function_expression::hir() both tried to verify
that 'out' and 'inout' parameters used l-values. Irritatingly, it
turned out that this was not redundant; both checks caught -some- cases.

This patch combines the two into a single "complete" function that does
all the parameter mode checking. It also adds a comment clarifying why
AST-level checking is necessary in the first place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_function.cpp
909e8899671a45bcc865fe303a8cb697a25634aa 29-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Split up function matching and call generation a bit more.

We used to have one big function, match_signature_by_name, which found
a matching signature, performed out-parameter conversions, and generated
the ir_call. As the code for matching against built-in functions became
more complicated, I split it internally, creating generate_call().

However, I left the same awkward interface. This patch splits it into
three functions:
1. match_signature_by_name()

This now takes a name, a list of parameters, the symbol table, and
returns an ir_function_signature. Simple and one purpose: matching.

2. no_matching_function_error()

Generate the "no matching function" error and list of prototypes.
This was complex enough that I felt it deserved its own function.

3. generate_call()

Do the out-parameter conversion and generate the ir_call. This
could probably use more splitting.

The caller now has a more natural workflow: find a matching signature,
then either generate an error or a call.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_function.cpp
0405bd08ca0e01ebc68891ee1ff47d320983f775 28-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't trust loop analysis in the presence of function calls.

Function calls may have side effects that alter variables used inside
the loop. In the fragment shader, they may even terminate the shader.
This means our analysis about loop-constant or induction variables may
be completely wrong.

In general it's impossible to determine whether they actually do or not
(due to the halting problem), so we'd need to perform conservative
static analysis. For now, it's not worth the complexity: most functions
will be inlined, at which point we can unroll them successfully.

Fixes Piglit tests:
- shaders/glsl-fs-unroll-out-param
- shaders/glsl-fs-unroll-side-effect

NOTE: This is a candidate for release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
oop_analysis.cpp
oop_analysis.h
4123d0b32138a0fbdbc7f61380d041704ba0ad43 31-Mar-2012 Vinson Lee <vlee@freedesktop.org> linker: Fix memory leak in count_uniform_size::visit_field.

Fixes a Coverity resource leak defect.

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
7449ae45974c6cfd872c1dc2e73bbccdb11d0f70 20-Nov-2011 Dave Airlie <airlied@redhat.com> glsl: fix linker error message context for frag shader output.

A later error prints this properly, fix this case to do the same.

v2: remove attribute as per Ian's suggestion
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
7a348b91ce983c7efb1db61f36083f7d8d088f26 13-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Make ir_dereference_variable ctor assert the variable exists.

This also seems like a bad idea. There were too many instances for me
to thoroughly scan the code as I did with the last two patches, but a
quick scan indicated that most callers newly allocate a variable,
dereference it, or NULL-check. In some cases, it wasn't clear that the
value would be non-NULL, but they didn't check for error_type either.

At any rate, not checking for this is a bug, and assertions will trigger
it earlier and more reliably than returning error_type.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.cpp
dca19a771156685895892740f687cee7cf84a8c9 13-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Explicitly NULL-check variables before making a dereference.

The constructor currently returns a ir_dereference_variable of error
type when provided NULL, but that's about to change in the next commit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
st_to_hir.cpp
2cd652f810e3417ff458f23a8c72a0c84e342258 13-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Make ir_dereference_record constructor assert the variable exists.

Providing a NULL pointer to the ir_dereference_record() constructor
seems like a bad idea. Currently, if provided NULL, it returns a
partially constructed value of error type. However, none of the callers
are prepared to handle that scenario.

Code inspection shows that all callers do one of the following:
- Already NULL-check the argument prior to creating the dereference
- Already deference the argument (and thus would crash if it were NULL)
- Newly allocate the argument.

Thus, it should be safe to simply assert the value passed is not NULL.
This should also catch issues right away, rather than dying later.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.cpp
25b0d45d038774406f2bb7173abc33a3cb261db2 13-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Make ir_dereference_array constructor assert the variable exists.

Providing a NULL pointer to the ir_dereference_array() constructor seems
like a bad idea. Currently, if provided NULL, it returns a partially
constructed value of error type. However, none of the callers are
prepared to handle that scenario.

Code inspection shows that all callers do one of the following:
- Already NULL-check the argument prior to creating the dereference
- Already deference the argument (and thus would crash if it were NULL)
- Newly allocate the argument.

Thus, it should be safe to simply assert the value passed is not NULL.
This should also catch issues right away, rather than dying later.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.cpp
ced54dcf9b496dbe0bf254673ecee37014c1ee3b 13-Mar-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Comment that expression flattening is used for matrix operations.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_expression_flattening.cpp
ba3a4d79a7bad959c0d9efbe0daa8d73c281d664 13-Mar-2012 Dave Airlie <airlied@redhat.com> glsl: fix compiling warning from gcc 4.7

ir_validate.cpp: In member function ‘virtual ir_visitor_status ir_validate::visit_leave(ir_swizzle*)’:
ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::x’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::y’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::z’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::w’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
r_validate.cpp
b78a77f979b21a84aecb6fa4f19a2ed51a48c306 13-Mar-2012 Dave Airlie <airlied@redhat.com> glsl: initialise const force glsl extension warning in fake ctx

valgrind complained about an uninitialised value being used in
glsl_parser_extras.cpp, and this was the one it was giving out about.

Just initialise the value in the fakectx.

Signed-off-by: Dave Airlie <airlied@redhat.com>
uiltins/tools/generate_builtins.py
7feabfe23dc54960abba34755f484f786575ac49 21-Mar-2012 Brian Paul <brianp@vmware.com> glsl: propagate MaxUnrollIterations to the optimizer's loop unroller

Instead of the hard-coded value of 32. Note that MaxUnrollIterations
defaults to 32 so there's no net change. But the gallium state tracker
can override this.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
f1c1c9eabea3c38110dc4312bc6cb4319bb82130 20-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Don't require gl_Position to be written in GLSL 1.40.

Fixes piglit glsl-1.40/execution/tf-no-position.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
b41ab3b42c989926389e599d5794412a628f277f 16-Mar-2012 Paul Berry <stereotype441@gmail.com> Add .deps/, .libs/, and *.la to toplevel .gitignore

To avoid redundancies, this patch also removes .deps, .libs, and *.la
from .gitignore files in subdirectories.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/.gitignore
0225a15b6907b51dbbc9602a1f0cb07ee809f496 15-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Don't include the deprecated structure types in GLSL 1.40.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_types.cpp
lsl_types.h
c0795742a38e0aab59309c1ec71d980e493237e2 12-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add GLSL 1.40 textureSize() implementations for sampler2DRect.

By setting lod to 0 in the builtin function implementation, we avoid
needing to update all the visitors to ignore LOD in this case, when
the hardware drivers actually want to ask for LOD 0 for rectangular
textures.

Fixes piglit spec/GLSL-1.40/textureSize-*Rect.

v2: Change style of looking for substrings.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/140.frag
uiltins/profiles/140.vert
uiltins/tools/texture_builtins.py
e06ab8c3632b748ffb59e1a82e7c966010a675e2 13-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Set up generated builtin functions handling for GLSL 1.40.

Otherwise, when we go to use ir_reader on the generated code, we won't
have the types present.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/tools/generate_builtins.py
3645b77b7162913b504a49fc42d785fde27df3f3 12-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add support for integer sampler2DRect variants in GLSL 1.40.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltin_types.h
lsl_types.cpp
lsl_types.h
c72840630b9f058e5eebfa45c59448582b08def3 12-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Drop ftransform() from GLSL 1.40 profile.

This is the one builtin function claimed to be dropped due to the
ARB_compatibility split.

Fixes piglit spec/GLSL-1.40/compiler/ftransform.vert

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/140.vert
590ad64fc84ffb013943f888e9e2321c034a0bb8 12-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Copy GLSL 1.30 builtin profile to GLSL 1.40.

All that's changed is the #version changing to 140.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/profiles/140.frag
uiltins/profiles/140.vert
25c729bf9f373c6b590ef6647e560f33a954f38b 12-Mar-2012 Eric Anholt <eric@anholt.net> glsl: When failing to compile some builtins, print the error.

This makes the process slightly more debuggable, though it would be
nice if the build just failed immediately instead.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/tools/generate_builtins.py
497aab39f0dea48707f9414f318365839132ed75 12-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Let the builtin compiler process GLSL 1.40 shaders.

This is required to put the new 1.40 builtins in place, since they
require new types.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ain.cpp
177ccd246f8c2a411b9f97c45c9d7a4f6c9e7721 09-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Update builtin variables for GLSL 1.40.

Mostly this is a matter of removing variables that have been moved to
the compatibility profile. There's one addition: gl_InstanceID is
present in the core now.

This fixes the new piglit tests for GLSL 1.40 builtin variables.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltin_variables.cpp
c5ff9a8b9e3cafb3764e620add2900656c59606b 08-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Hook up the current GLSL 1.30 types and builtins for 1.40.

This gets a basic #version 140 shader compiling.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltin_variables.cpp
lsl_types.cpp
inker.cpp
ac5a5b324335195b5a5ed98775ce442c573e7e1d 08-Mar-2012 Eric Anholt <eric@anholt.net> glsl: Add support for parsing #version 140.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser.yy
lsl_parser_extras.cpp
lsl_parser_extras.h
ead3589aa2810b66164178a1d55d2063cfa3b041 08-Feb-2012 Eric Anholt <eric@anholt.net> glsl: Avoid extra if statements for logic and/or with no side effects.

This avoids extra if statements in the common case of just comparing
two expressions that don't involve assignments or function calls,
along with simplifying the handling of constant expressions. Reduces
i965 instructions generated in unigine tropics and sanctuary,
yofrankie, warsow, gstreamer shaders, and the weston compositor.

shader-db results:
Total instructions: 213052 -> 212752
38/1246 programs affected (3.0%)
14309 -> 14009 instructions in affected programs (2.1% reduction)
st_to_hir.cpp
be5f27a84d0d4efb57071d9d7ecda061223d03ef 21-Feb-2012 Eric Anholt <eric@anholt.net> glsl: Refine the loop instruction counting.

Before, we were only counting top-level instructions. But if we have
an assignment of a giant expression tree (such as the ones eventually
generated by glsl-fs-unroll), we were counting the same as an
assignment of a variable deref.

glsl-fs-unroll-explosion now fails in a reasonable amount of time on
i965 because the unrolling didn't go ridiculously far.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
oop_unroll.cpp
1e6a2c10590bc6b4112ec2e54e1de7d8f9fd349d 29-Feb-2012 Ian Romanick <ian.d.romanick@intel.com> glsl: Make gl_InstanceID available with GL_ARB_draw_instanced extension

Originally ARB_draw_instanced only specified that ARB decorated name.
Since no vendor actually implemented that behavior and some apps use
the undecorated name, the extension now specifies that both names are
available.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
uiltin_variables.cpp
b823b99ec0f13af257dcd885f436a4d294c6222a 10-Feb-2012 Kenneth Graunke <kenneth@whitecape.org> glcpp: Don't strlen() the output for every token being printed.

The ralloc string appending functions were originally intended for
simple, non-hot-path uses like printing to an info log.

Cuts Unigine Tropics load time by around 20% (6 seconds).

v2: Avoid strlen() on every newline, too.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> [v1]
Acked-by: José Fonseca <jfonseca@vmware.com> [v1]
lcpp/glcpp-parse.y
lcpp/glcpp.h
8292b7419d0405e94a5ea270ba710d20f0eb071f 10-Feb-2012 Kenneth Graunke <kenneth@whitecape.org> ralloc: Make rewrite_tail increase "start" by the new text's length.

Both callers of rewrite_tail immediately compute the new total string
length by adding the (known) length of the existing string plus the
length of the newly appended text. Unfortunately, callers generally
won't know the length of the new text, as it's printf-formatted.

Since ralloc already computes this length, it makes sense to add it in
and save the caller the effort. This simplifies both existing callers,
but more importantly, will allow for cheap-appending in the next commit.

v2: The link_uniforms code needs both the old and new length.
Apply the obvious fix (which sadly makes it less of a cleanup).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> [v1]
Acked-by: José Fonseca <jfonseca@vmware.com> [v1]
ink_uniforms.cpp
inker.h
alloc.c
alloc.h
67007080b716c7e51039a381f407ababd68230f7 25-Jan-2012 Mathias Fröhlich <Mathias.Froehlich@gmx.net> glsl: Avoid excessive loop unrolling.

Avoid unrollong loops that are either nested loops or
where the loop body times the unroll count is huge.

The change is far from being perfect but it extends the
loop unrolling decision heuristic by some additional
safeguard. In particular this cuts down compilation of
a shader precomputing atmospheric scattering integral
tables containing two nesting levels in a loop from
something way beyond some minutes (I never waited for
it to finish) to some fractions of a second.

This fixes piglit tests glsl-fs-unroll-explosion and
glsl-vs-unroll-explosion on r600g.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
oop_unroll.cpp
5497cc428fa7c6670d252d34f4a67c9498ae3895 09-Feb-2012 Chad Versace <chad.versace@linux.intel.com> glsl: Fix Android build

The build was broken by the line below, added in commit 4f82fed4.
s_expression.cpp:26: #include <limits>

Mesa's half of the fix is to add 'external/astl/include' to the include
path. The other half of the fix requires implementing
numeric_limits<float>::infinity() in astl, for which I have patches
submitted upstream for review.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
ndroid.mk
57e44371a5b6aa8122b6a482ed6bd33e797ea1d2 30-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Add error case for switch() with two default cases.

Fixes piglit switch-case-duplicated.vert.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
lsl_parser_extras.h
140632190cf41e6a035ca199b181091d4ed46986 30-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Throw an error when faced with a duplicated switch() case label.

The error message I chose matches gcc's error. Fixes piglit
switch-case-duplicated.vert.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
lsl_parser_extras.h
01a5a2c9d761d4c9d72c236084efee700dcb28b8 30-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Add other missing error location information for switch statements.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
663dcbbffeaedf0643e7e9d930ccfbcd698d1d9c 30-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Add missing location info to case labels.

Otherwise, the upcoming error messages said the location was 0:0(0).

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser.yy
2c3e10e71935506798c413363df27afc4348fb53 28-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Throw the required error when a case label is a non-constant.

It's not quite spelled out in the spec text, but the grammar indicates
that only constant values are allowed as switch() case labels (and
only constant values make sense, anyway).

Fixes piglit glsl-1.30/compiler/switch-statement/switch-case-uniform-int.vert.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
22d81f154fed9e004cca91807808ae3b81b01ced 28-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Save and restore the whole switch state for nesting.

This stuffs them all in a struct for sanity. Fixes piglit
glsl-1.30/execution/switch/fs-uniform-nested.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
lsl_parser_extras.cpp
lsl_parser_extras.h
84a1273e7fe1216a4724ab13cd061a12b48893c2 03-Feb-2012 Brian Paul <brianp@vmware.com> glsl: move array_sizing_visitor class outside of link_intrastage_shaders()

To silence warnings with gcc 4.4.x on Linux and llvm-g++ 4.2 on Mac.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
cd2e2187cb45accb13bf89ef297324332c46f379 02-Feb-2012 Carl Worth <cworth@cworth.org> glsl: Avoid ralloc_stealing a long-lived object to a short-lived parent

In commit 6ecee54a9aecc120cb68b02f7e14dcac86b9eca2 a call to
talloc_reference was replaced with a call to talloc_steal. This was in
preparation for moving to ralloc which doesn't support reference
counting.

The justification for talloc_steal within token_list_append in that
commit is that the tokens are being copied already. But the copies are
shallow, so this does not work.

Fortunately, the lifetime of these tokens is easy to understand. A
token list for "replacements" is created and stored in a hash table
when a function-like macro is defined. This list will live until the
macro is #undefed (if ever).

Meanwhile, a shallow copy of the list is created when the macro is
used and the list expanded. This copy is short-lived, so is unsuitable
as a new parent.

So we can just let the original, longer-lived owner continue to own
the underlying objects and things will work.

This fixes bug #45082:

"ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106'
failed." when using a macro in GLSL
https://bugs.freedesktop.org/show_bug.cgi?id=45082

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

NOTE: This is a candidate for stable release branches.
lcpp/glcpp-parse.y
64fd26a8a812f66f1291d897df7953b8ac9e2f1b 02-Feb-2012 Carl Worth <cworth@cworth.org> glsl: Add glcpp tests for a macro used twice

This test cases exposes a bug as described in this bug report:

"ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106'
failed." when using a macro in GLSL
https://bugs.freedesktop.org/show_bug.cgi?id=45082

Clearly, some memory is getting (incorrectly) freed on the first macro
invocation, leading to problems with the second macro invocation.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/tests/101-macros-used-twice.c
lcpp/tests/101-macros-used-twice.c.expected
7ab1c7f7926c75a07f33eb149d0fc17dcfaffd5e 21-Jan-2012 Carl Worth <cworth@cworth.org> glcpp: Fix so that trailing punctuation does not prevent macro expansion

The trick here is that flex always chooses the rule that matches the most
text. So with a input text of "two:" which we want to be lexed as an
IDENTIFIER token "two" followed by an OTHER token ":" the previous OTHER
rule would match longer as a single token of "two:" which we don't want.

We prevent this by forcing the OTHER pattern to never match any
characters that appear in other constructs, (no letters, numbers, #,
_, whitespace, nor any punctuation that appear in CPP operators).

Fixes bug #44764:

GLSL preprocessor doesn't replace defines ending with ":"
https://bugs.freedesktop.org/show_bug.cgi?id=44764

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

NOTE: This is a candidate for stable release branches.
lcpp/glcpp-lex.l
e931b0e05b19259b0f5b53faf73b375013ab1cb3 21-Jan-2012 Carl Worth <cworth@cworth.org> glcpp: Add new test showing bug where a trailing ':' prevents macro expansion

This demonstrates a bug that was recently triggered in piglit.

Here is the original bug report (containing a test case almost identical
to this one):

https://bugs.freedesktop.org/show_bug.cgi?id=44764

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/tests/100-macro-with-colon.c
lcpp/tests/100-macro-with-colon.c.expected
a99164956f1ade01909123ba196ef01282f41675 01-Feb-2012 Matt Turner <mattst88@gmail.com> Revert "automake: src/glsl and src/glsl/glcpp"

This reverts commit 9947656168d09f9019600fccc42ca8e0de49b83a.
gitignore
akefile
akefile.am
lcpp/.gitignore
lcpp/Makefile.am
70dd17152dca228675f955da41bc9d285c6177d4 01-Feb-2012 Matt Turner <mattst88@gmail.com> Revert "src/glsl/glcpp: wire up glcpp-test to make check"

This reverts commit 2bb9f9e1fda61fceb9284cbb4619d7e60e39f190.
lcpp/Makefile.am
lcpp/tests/glcpp-test
2bb9f9e1fda61fceb9284cbb4619d7e60e39f190 29-Jan-2012 Matt Turner <mattst88@gmail.com> src/glsl/glcpp: wire up glcpp-test to make check

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Matt Turner <mattst88@gmail.com>
lcpp/Makefile.am
lcpp/tests/glcpp-test
82060adcde88eb57cc0a3b71d23f003f5637986f 29-Jan-2012 Matt Turner <mattst88@gmail.com> glcpp-test: don't return failure if valgrind tests aren't run

Success was (tests-passed AND valgrind-tests-passed) but this meant that
if the valgrind tests weren't run it would be considered a failure.

The logic is now (tests-passed AND (!valgrind OR valgrind-tests-passed))
which lets us return success if the valgrind tests aren't run.

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Matt Turner <mattst88@gmail.com>
lcpp/tests/glcpp-test
9947656168d09f9019600fccc42ca8e0de49b83a 27-Jan-2012 Matt Turner <mattst88@gmail.com> automake: src/glsl and src/glsl/glcpp

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Matt Turner <mattst88@gmail.com>
gitignore
akefile
akefile.am
lcpp/.gitignore
lcpp/Makefile.am
4ff8fd93e8e91672bb02543ecaa0c6e462a87551 29-Jan-2012 Matt Turner <mattst88@gmail.com> glsl: rename Makefile.sources' _SOURCES variables

automake uses variables named *_SOURCES.

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Matt Turner <mattst88@gmail.com>
ndroid.mk
akefile
akefile.sources
Conscript
e3b520049675f78065eccbc25c001ea77861c129 29-Jan-2012 Kenneth Graunke <kenneth@whitecape.org> glsl: Rename class variable_entry to ir_variable_refcount_entry.

Exporting a publicly visible class with a generic name like
"variable_entry" via ir_variable_refcount.h is kind of mean.

Many IR transformers would like to define their own "variable_entry"
class. If they accidentally include this header, the compiler/linker
may get confused and try to instantiate the wrong variable_entry class,
leading to bizarre runtime crashes.

The hope is that renaming this one will allow .cpp files to safely
declare and use their own file-scope "variable_entry" classes.

This avoids crashes caused by converting src/glsl to automake.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-and-tested-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_variable_refcount.cpp
r_variable_refcount.h
pt_dead_code.cpp
pt_tree_grafting.cpp
b9e27cc1426e3242a003fa5ae91fab330694009a 18-Jan-2012 Eric Anholt <eric@anholt.net> mesa: Add a flag for forcing all GLSL extensions to "warn".

NOTE: This is a candidate for the 8.0 branch.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser_extras.cpp
873f3ae92e1d8a17ea228b38b4c20346d54ae045 22-Jan-2012 Alexander von Gluck <kallisti5@unixzen.com> glsl: Don't use newlocale on Haiku

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Brian Paul <brianp@vmware.com>
trtod.c
e9bcf4d56b8ae128204fb95693c6f81a6b724052 17-Jan-2012 Vinson Lee <vlee@freedesktop.org> glsl: Fix 'control reaches end of non-void function' warning.

Fix this GCC warning on non-debug builds.
glsl_types.cpp: In member function 'gl_texture_index
glsl_type::sampler_index() const':
glsl_types.cpp:157: warning: control reaches end of non-void function

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_types.cpp
d540af554adfe302387014c0f46d6ac3aaa75121 20-Jan-2012 Christoph Bumiller <e0425955@student.tuwien.ac.at> mesa: allocate transform_feedback_info::Outputs array dynamically

The nvc0 gallium driver is advertising 128 MAX_INTERLEAVED_COMPS
which made it always assert in the linker when TFB was used since
the Outputs array was smaller than that maximum.

v2: added assertions

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
inker.cpp
4f82fed49359676fc19598f8c65ca51958dd2d79 17-Jan-2012 Paul Berry <stereotype441@gmail.com> glsl: Fix isinf() for non-C99-compliant compilers.

Commit ede60bc4670a8d9c14921c77abee1ac57fc0e6bf (glsl: Add isinf() and
isnan() builtins) uses "+INF" in the .ir file to represent infinity.
This worked on C99-compliant compilers, since the s-expression reader
uses strtod() to read numbers, and C99 requires strtod() to understand
"+INF". However, it didn't work on non-C99-compliant compilers such
as MSVC.

This patch modifies the s-expression reader to explicitly check for
"+INF" rather than relying on strtod() to support it.

This is a candidate for the 8.0 branch.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44767
Tested-by: Morgan Armand <morgan.devel@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
_expression.cpp
aad3a46ff453d33cb3df909903d261f67b452d31 12-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Fix leak of linked uniform names at relink/free of the shader_program.

NOTE: This is a candidate for the 8.0 branch.
ink_uniforms.cpp
5a0f395bcf70e524492e766a07cf0b816b42a20d 12-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Fix leak of LinkedTransformFeedback.Varyings.

I copy-and-pasted the thing I was allocating for as the context, so
the first time it would be NULL (root of a ralloc context) and they'd
chain off each other from then on.

NOTE: This is a candidate for the 8.0 branch.
inker.cpp
6c0df75803e1944f82a1468dcca47d23de82ea6b 15-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Calculate used samplers and shadow samplers in the linker

It used to be done in ir_to_mesa, and that was kind of a bad place.

I didn't change st_glsl_to_tgsi because there is some strange stuff
happening in the code that generates glDrawPixels shaders. It looked
like this would break horribly if I touched anything.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
6a992c3288b6f7a5d94172c9ad1908e71e58233e 15-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Calculate the sampler to texture target mapping during linking

Track the calculated data in gl_shader_program instead of the
individual assembly shaders.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
32be81de39f7548e353afabf1215b0ea7c7b0916 14-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add glsl_type::sampler_index

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_types.cpp
lsl_types.h
d3150ebc8c1833322daf24b2cd47e31a5b2f8a1f 09-Jan-2012 Paul Berry <stereotype441@gmail.com> mesa: Move transform feedback error check to reduce array overflow risk.

Previous to this patch, we didn't do the limit check for
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS until the end of the
store_tfeedback_info() function, *after* storing all of the transform
feedback info in the gl_transform_feedback_info::Outputs array. This
meant that the limit check wouldn't prevent us from overflowing the
array and corrupting memory.

This patch moves the limit check to the top of tfeedback_decl::store()
so that there is no risk of overflowing the array. It also adds
assertions to verify that the checks for
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS and
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS are sufficient to avoid
array overflow.

Note: strictly speaking this patch isn't necessary, since the maximum
possible number of varyings is MAX_VARYING (16), whereas the size of
the Outputs array is MAX_PROGRAM_OUTPUTS (64), so it's impossible to
have enough varyings to overflow the array. However it seems prudent
to do the limit check before the array access in case these limits
change in the future.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
642e5b413e0890b2070ba78fde42db381eaf02e5 04-Jan-2012 Paul Berry <stereotype441@gmail.com> mesa: Fix transform feedback of unsubscripted gl_ClipDistance array.

On drivers that set gl_shader_compiler_options::LowerClipDistance (for
example i965), we need to handle transform feedback of gl_ClipDistance
specially, to account for the fact that the hardware represents it as
an array of vec4's rather than an array of floats.

The previous way this was accounted for (translating the request for
gl_ClipDistance[n] to a request for a component of
gl_ClipDistanceMESA[n/4]) doesn't work when performing transform
feedback on the whole unsubscripted array, because we need to keep
track of the size of the gl_ClipDistance array prior to the lowering
pass. So I replaced it with a boolean is_clip_distance_mesa, which
switches on the special logic that is needed to handle the lowered
version of gl_ClipDistance.

Fixes Piglit tests "EXT_transform_feedback/builtin-varyings
gl_ClipDistance[{1,2,3,5,6,7}]-no-subscript".

Reviewed-by: Eric Anholt <eric@anholt.net>
inker.cpp
be4e9f7a0ccb7aa0edef5e5b589bdbbfd4eab3cb 04-Jan-2012 Paul Berry <stereotype441@gmail.com> mesa: Fix computation of transform feedback num_components.

The function tfeedback_decl::num_components() was not correctly
accounting for transform feedback of whole arrays and gl_ClipDistance.
The bug was hard to notice in tests, because it only affected the
checks for MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS and
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS.

This patch fixes the computation, and adds an assertion to verify
num_components() even when MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS
and MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS are not exceeded.

The assertion requires keeping track of components_so_far in
tfeedback_decl::store(); this will be useful in a future patch to fix
non-multiple-of-4-sized gl_ClipDistance.

Reviewed-by: Eric Anholt <eric@anholt.net>
inker.cpp
916e206ef0cbcc5fa6c4026135e92079e1d73ec2 10-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Add error checking for applying interpolation qualifiers to other vars.

Fixes piglit
glsl-1.30/compiler/interpolation-qualifiers/local-smooth-01.frag.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
057f9ae54b5efb0020cc0c049d50e778de3f3f7a 09-Jan-2012 Eric Anholt <eric@anholt.net> glsl: Fix copy_propagation_elements bug in handling self-copies.

We were doing the kill of the updated channels, then adding our copy
to the list of available stuff to copy. But if the copy was updating
its own source channels, we didn't notice, breaking this code:

R0.xyzw = arg0 + arg1;
R0.xyzw = R0.wwwx;
gl_FragColor.xyzw = clamp(R0.xyzw, 0.0, 1.0);

Fixes piglit glsl-copy-propagation-self-2.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_copy_propagation_elements.cpp
6c29452f38dacace4f234e9526bfdc1e23fb5051 06-Jan-2012 Andy Clayton <q3aiml@gmail.com> glsl: fix glsl optimization infinite loop from copy_propagation_elements

The trick was to produce an assignment in the IR along the lines of:

(assign (xyzw) (var_ref R0) (swiz wwww (var_ref R0) ))

which occurs only rarely even in code that looks like it should do
this, because of the assignment temporaries generated in ast_to_hir.

From the IR above, this optimization pass would then propagate
references of R0 into R0.wwww (seems reasonable), but without this
patch, a later reference of R0.wwww would see R0 first, turning that
into R0.wwww.wwww, which triggered opt_swizzle_swizzle, and then we
looped back to this code to do it again. Avoid that by skipping over
the usual ir_rvalue visitor's ir_swizzle hook, so that we get
handle_rvalue() on the ir_swizzle itself, not its referenced value.
Looking at only the swizzle will always optimize away at least as much
as looking at the swizzle's refererenced value.

We now still claim to propagate r0.w into r0.w, but at least we don't
trigger the loop.

v2: Rewrite commit message (changes by anholt)

Fixes piglit glsl-copy-propagation-self-1
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=34006
pt_copy_propagation_elements.cpp
108cba21dec82a7e10962cf01f2835e7b950ff74 05-Jan-2012 Paul Berry <stereotype441@gmail.com> mesa: Fix bogus transform feedback error message when subscripting non-array.

Previous to this patch, if the client requested transform feedback
using a subscript, but the variable was not an array
(e.g. "gl_FrontColor[0]"), we would produce a bogus error message like
"Transform feedback varying gl_FrontColor[0] found, but it's an array
([] expected)".

Changed the error message to e.g. "Transfrorm feedback varying
gl_FrontColor[0] requested, but gl_FrontColor is not an array."

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
be21ded2aef97b134379dd92b67e5e206720c1b1 05-Jan-2012 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Add missing mix(genType, genType, bvec) built-ins.

The IR for mix(float, float, bool) was missing a write mask, causing the
IR reader to die horribly. Furthermore, I neglected to add any of the
new prototypes to the 1.30 profiles.

Fixes oglconform's glsl-bif-com advanced.mix test cases.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44477
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/ir/mix.ir
uiltins/profiles/130.frag
uiltins/profiles/130.vert
1f125374e73d1718cd54c946826c76b09998c055 23-Dec-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Don't mark assignment temporaries as read-only

The various l-value errors this was designed to catch are now caught
by other means. Marking the temporaries as read-only now just
prevents sensible error messages from being generated. It's

0:0(0): error: function parameter 'out p' references the read-only variable '_post_incdec_tmp'

versus

0:13(5): error: function parameter 'out p' references a post-decrement operation

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
st_to_hir.cpp
208b5b113faab324854d457c3ad4abf05cafedd1 23-Dec-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Emit extra errors for l-value violations in 'out' or 'inout' parameters

Somethings, like pre-increment operations, were not previously caught.
After the 8.0 release, this code needs some major refactoring and
clean-up. It's a mess. :(

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42755
st_function.cpp
e9015e99d0d702570dbd3d7bcbafbf6c723cb7a7 23-Dec-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Emit errors for assignments to non-l-value expressions

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42755
st_to_hir.cpp
fa0a9ac5cdf49865cfc289c4326c73c9dd4a61c5 23-Dec-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Track descriptions of some expressions that can't be l-values

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
st.h
st_to_hir.cpp
lsl_parser_extras.cpp
6d4b35c03619148cde89bc5eedaac3288001edd3 03-Jan-2012 Vincent Lejeune <vljn@ovi.com> glsl: Add a lowering pass to remove reads of shader output variables.

This is similar to Gallium's existing glsl_to_tgsi::remove_output_read
lowering pass, but done entirely inside the GLSL compiler.

Signed-off-by: Vincent Lejeune <vljn@ovi.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
akefile.sources
r_optimization.h
ower_output_reads.cpp
33fe02111605ec8897dbc1c989c137b6e38c02f8 04-Jan-2012 Paul Berry <stereotype441@gmail.com> mesa: Fix transform feedback of unsubscripted arrays.

It is not explicitly stated in the GL 3.0 spec that transform feedback
can be performed on a whole varying array (without supplying a
subscript). However, it seems clear from context that this was the
intent. Section 2.15 (TransformFeedback) says this:

When writing varying variables that are arrays, individual array
elements are written in order.

And section 2.20.3 (Shader Variables), says this, in the description
of GetTransformFeedbackVarying:

For the selected varying variable, its type is returned into
type. The size of the varying is returned into size. The value in
size is in units of the type returned in type.

If it were not possible to perform transform feedback on an
unsubscripted array, the returned size would always be 1.

This patch fixes the linker so that transform feedback on an
unsubscripted array is supported.

Fixes piglit tests "EXT_transform_feedback/builtin-varyings
gl_ClipDistance[{4,8}]-no-subscript" and
"EXT_transform_feedback/output_type *[2]-no-subscript".

Note: on back-ends that set
gl_shader_compiler_options::LowerClipDistance (for example i965),
tests "EXT_transform_feedback/builtin-varyings
gl_ClipDistance[{1,2,3,5,6,7}]" still fail. I hope to address this in
a later patch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
456279bb33e09679de61d560aeafa74bb902fe43 27-Dec-2011 Paul Berry <stereotype441@gmail.com> mesa: Fix transform feedback of gl_ClipDistance.

On drivers that set gl_shader_compiler_options::LowerClipDistance (for
example i965), references to gl_ClipDistance (a float[8] array) will
be converted to references to gl_ClipDistanceMESA (a vec4[2] array).

This patch modifies the linker so that requests for transform feedback
of gl_ClipDistance are similarly converted.

Fixes Piglit test "EXT_transform_feedback/builtin-varyings
gl_ClipDistance".

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
913a5c238b76a84616917dd47c3c7f627c892e58 27-Dec-2011 Paul Berry <stereotype441@gmail.com> mesa: Make tfeedback_decl::var_name a const char *.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
2169331d40e915d0d1065477a5c81d59f222a5c8 27-Dec-2011 Paul Berry <stereotype441@gmail.com> mesa: Add gl_transform_feedback_info::ComponentOffset.

When using transform feedback, there are three circumstances in which
it is useful for Mesa to instruct a driver to stream out just a
portion of a varying slot (rather than the whole vec4):

(a) When a varying is smaller than a vec4, Mesa needs to instruct the
driver to stream out just the first one, two, or three components of
the varying slot.

(b) In the future, when we implement varying packing, some varyings
will be offset within the vec4, so Mesa will have to instruct the
driver to stream out an arbitrary contiguous subset of the components
of the varying slot (e.g. .yzw or .yz).

(c) On drivers that set gl_shader_compiler_options::LowerClipDistance,
if the client requests that an element of gl_ClipDistance be streamed
out using transform feedback, Mesa will have to instruct the driver to
stream out a single component of one of the gl_ClipDistance varying
slots.

Previous to this patch, only (a) was possible, since
gl_transform_feedback_info specified only the number of components of
the varying slot to stream out. This patch adds
gl_transform_feedback_info::ComponentOffset, which indicates which
components should be streamed out.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
1be0fd8c86cac0775fd4451eb332effc70ccdbe5 05-Jan-2012 Paul Berry <stereotype441@gmail.com> mesa: Fix extra memset in store_tfeedback_info()

Commit 9d36c96d6ec9f2c05c8e0b9ef18c5462cddee8c1 (mesa: Fix
glGetTransformFeedbackVarying()) accidentally added an extra memset()
call to the store_tfeedback_info() function, causing
prog->LinkedTransformFeedback.NumBuffers to be erased.

This patch removes the extra memset and rearranges the other
operations in store_tfeedback_info() to be in the correct order.

Fixes piglit tests "EXT_transform_feedback/api-errors *unbound*"

Reviewed-by: Eric Anholt <eric@anholt.net>
inker.cpp
9d36c96d6ec9f2c05c8e0b9ef18c5462cddee8c1 03-Jan-2012 Eric Anholt <eric@anholt.net> mesa: Fix glGetTransformFeedbackVarying().

The current implementation was totally broken -- it was looking in an
unpopulated structure for varyings, and trying to do so using the
current list of varying names, not the list used at link time.

v2: Fix leaking of memory into the program per re-link.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
inker.cpp
cb96b06130c7728fe5838845325571ed18f6e983 24-Dec-2011 Matt Turner <mattst88@gmail.com> glsl: rename VERSION to VERSION_TOK for automake

Signed-off-by: Matt Turner <mattst88@gmail.com>
lsl_lexer.ll
lsl_parser.yy
ebfad9f6a125738b9bfc5d5f7d09a8b57856674a 30-Dec-2011 Paul Berry <stereotype441@gmail.com> mesa: Check that all buffers are bound in BeginTransformFeedback.

From the EXT_transform_feedback spec:

The error INVALID_OPERATION is generated by
BeginTransformFeedbackEXT if any transform feedback buffer object
binding point used in transform feedback mode does not have a
buffer object bound.

This required adding a new NumBuffers field to the
gl_transform_feedback_info struct, to keep track of how many transform
feedback buffers are required by the current program.

Fixes Piglit tests:
- EXT_transform_feedback/api-errors interleaved_unbound
- EXT_transform_feedback/api-errors separate_unbound_0_1
- EXT_transform_feedback/api-errors separate_unbound_0_2
- EXT_transform_feedback/api-errors separate_unbound_1_2

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
inker.cpp
39464489510270bbe472d11f7614c04ce1b6ae33 24-Dec-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Don't use base type for bit-not when there's an error

Other parts of the compiler assume that expressions will have
well-formed types or the error type. Just using the type of the thing
being operated on can cause expressions like ~3.14 or ~false to not
have a well-formed type. This could then result in an assertion
failure in the context epxression handler.

If there is an error processing the expression, set the type of the IR
expression to error.

Fixes piglit's bit-not-0[789].frag tests.

NOTE: This is a candidate for the 7.11 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42755
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: Vinson Lee <vlee@vmware.com>
st_to_hir.cpp
141d961d847111b2596f9c3094d5ebf1639c8c24 30-Dec-2011 Alexander von Gluck <kallisti5@unixzen.com> glsl: fix usage of potentially undefined data_end union

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
ink_uniforms.cpp
7a8f52e4b4c0bded4f3c98333ca1403fa8085533 24-Dec-2011 Matt Turner <mattst88@gmail.com> glsl: remove old autogen.sh

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
utogen.sh
942d452047431f7463d3fad5e7cb92dfd81fd0ac 06-Dec-2011 Paul Berry <stereotype441@gmail.com> mesa: Record transform feedback strides/offsets in linker output.

This patch adds two new fields to the gl_transform_feedback_info
struct:

- BufferStride records the total number of components (per vertex)
that transform feedback is being instructed to store in each buffer.

- Outputs[i].DstOffset records the offset within the interleaved
structure of each transform feedback output.

These values are needed by the i965 gen6 and r600g back-ends, so it
seems better to have the linker provide them rather than force each
back-end to compute them independently.

Also, DstOffset helps pave the way for supporting
ARB_transform_feedback3, which allows the transform feedback output to
contain holes between attributes by specifying
gl_SkipComponents{1,2,3,4} as the varying name.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
inker.cpp
c87cb98bb4e893e04831bf68231f5ed42e0b5b6f 08-Dec-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix crashes caused by Bison error messages involving "'%'".

Invalid shaders containing the character % at an unexpected location
would cause Bison to call yyerror with a message of:

syntax error, unexpected '%'

Bison expects yyerror() to take a string, while _mesa_glsl_error() is a
printf-style function. This hit the classic printf string escape issue:

_mesa_glsl_error(loc, state, "unexpected '%'"); // invalid!
_mesa_glsl_error(loc, state, "%s", "unexpected '%'"); // correct.

This caused assertion failures after ralloc_asprintf_append called
vsnprintf to determine the length of the text that would be printed:
vsnprintf would see the invalid format and return -1, an invalid length.

The solution is to define a proper yyerror() wrapper function that calls
_mesa_glsl_error with the "%s". Since we compile with -p "_mesa_glsl",
yyerror is defined as:

#define yyerror _mesa_glsl_error

So we have to #undef yyerror in order to be able to declare it.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=43564
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
lsl_parser.yy
df809ae92343bb83c162ea4c807cefb67686717d 10-Dec-2011 Marek Olšák <maraeo@gmail.com> mesa: add const flags to skip MaxVarying and MaxUniform linker checks (v2)

This is only temporary until a better solution is available.

v2: print warnings and add gallium CAPs

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
4558987818e1ff36e86592e9c5c0b5e181be9ec1 06-Dec-2011 Anuj Phogat <anuj.phogat@gmail.com> glsl: Fix samplerCubeShadow support in shader compiler

This patch fixes the samplerCubeShadow support in GLSL shader compiler.
shader compiler was picking the 'r' texture coordinate for shadow comparison
when the expected behaviour is to use 'q' texture coordinate in case of cube
shadow maps.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/tools/texture_builtins.py
98ebe833fea8060ae2b0211e4fe9990f0670bb20 02-Dec-2011 Brian Paul <brianp@vmware.com> glsl: return visit_stop in ir_validate::visit_enter() to silence warning
r_validate.cpp
a92ee4abfe5c0bdd9cc921dee5f18436f1df8a4d 19-Nov-2011 Marek Olšák <maraeo@gmail.com> glsl: convervative_depth is not allowed in the vertex shader

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.cpp
6b43d6fdda13d73ca7b059f986ce2a2046bf03a0 19-Nov-2011 Marek Olšák <maraeo@gmail.com> glsl: finish up ARB_conservative_depth (v2)

v2: updated an error message

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
lsl_lexer.ll
lsl_parser.yy
bbcb648bc2f45dd85e33c7301527c8f6d97cbce6 19-Nov-2011 Marek Olšák <maraeo@gmail.com> mesa: rename the AMD_conservative_depth extension flag to ARB

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lcpp/glcpp-parse.y
lsl_parser_extras.cpp
151867b422d07b9e5845e95c2ebc30567809edc5 21-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Remove erroneous multiply by 4 in uniform usage calculation

The old count_uniform_size::num_shader_uniforms was actually
calculating the number of components used. Multiplying by 4 when
setting gl_shader::num_uniform_components caused us to count 4x as
many uniform components as were actually used.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42930
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42966
Acked-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Vinson Lee <vlee@vmware.com>
Tested-by: Pavel Ondračka <pavel.ondracka@email.cz>
Reviewed-and-tested-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
ec174a424489664626796126f937fbce3e7d8cd8 18-Nov-2011 Marek Olšák <maraeo@gmail.com> mesa: set the gl_FragDepth layout in the GLSL linker

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
90be99427a04a36973f9e3d19161065e1c5177b3 19-Nov-2011 Marek Olšák <maraeo@gmail.com> glsl: when cloning a variable, copy the depth layout too

This fixes AMD_conservative_depth.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_clone.cpp
5e3e9a8e9cbcd721a73c9f18edcd72a22b2de52d 15-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Add missing textureSize(samplerCubeShadow, int) variant.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
uiltins/tools/texture_builtins.py
f1a677cefbe91a5c1a72dbeda94d2f13a9369e54 11-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Always search for an exact function signature match.

Previously, we would fail to compile the following shader due to a bug
in lazy built-in importing:

#version 130
void main() {
float f = abs(5.0);
int i = abs(5);
}

The first call, abs(5.0), would fail to find a local signature, look
through the built-ins, and import "float abs(float)".

The second call, abs(5), would find the newly imported float signature
in the local shader, and settle for that. Unfortunately, it failed to
search the built-ins for the correct/exact signature, "int abs(int)".

Thus, abs(5) ended up being a float, causing a bizarre type error when
we tried to assign it to an int.

Fixes piglit test builtin-overload-matching.frag.

This is /not/ a candidate for stable branches, as it should only be
possible to trigger this bug using GLSL 1.30's built-in functions that
take integer arguments. Plus, the changes are fairly invasive.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
st_function.cpp
cdc94082664c329e6c55cf6053893360946275bf 09-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Split code to generate an ir_call out from match_function_by_name.

match_function_by_name performs two fairly separate tasks:
1. Hunt down the appropriate ir_function_signature for the callee.
2. Generate the actual ir_call (assuming we found the callee).

Both of these are complicated. The first has to handle exact/inexact
matches, lazy importing of built-in prototypes, different scoping rules
for 1.10, 1.20+, and ES. Not to mention printing a user-friendly error
message with pretty-printed "maybe you meant this" candidate signatures.

The second has to deal with void/non-void functions, pre-call implicit
conversions for "in" parmeters, and post-call "out" call conversions.

Trying to do both in one function is just too unwieldy. Time to split.

This patch purely moves the code to generate an ir_call into a separate
function and reindents it. Otherwise, the code is identical.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
st_function.cpp
861d0a5e12b1baa31211cb8aff983b8fb9b97482 11-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Add a new matching_signature() variant that returns exact/inexact.

When matching function signatures across multiple linked shaders, we
often want to see if the current shader has _any_ match, but also know
whether or not it was exact. (If not, we may want to keep looking.)

This could be done via the existing mechanisms:

sig = f->exact_matching_signature(params);
if (sig != NULL) {
exact = true;
} else {
sig = f->matching_signature(params);
exact = false;
}

However, this requires walking the list of function signatures twice,
which also means walking each signature's formal parameter lists twice.
This could be rather expensive.

Since matching_signature already internally knows whether a match was
exact or not, we can just return it to get that information for free.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
r.h
r_function.cpp
92f81590456103977988ee704d2e6119ca1b989d 08-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Validate resource usage in the linker

This is also done in ir_to_mesa and st_glsl_to_tgsi, but that code
will be removed soon.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
6ac895a664b25eb6252f33d5cfb0e9dd33190490 08-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Count the number of uniform components used by a shader during linking

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
812aa8839388042609f65ed00ae4fbfdb60a11d6 08-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Count the number of samplers used by a shader during linking

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_uniforms.cpp
b0cdeda4f290bceb214c760d6d23c01a673e6a87 14-Nov-2011 José Fonseca <jfonseca@vmware.com> glsl: Add missing ';' in action statement.

Addresses the warnings:

warning: a `;' might be needed at the end of action code
warning: future versions of Bison will not add the `;'
lsl_parser.yy
54346d1f9b31de531c202ffe26b72551326ad7ae 11-Nov-2011 Morgan Armand <morgan.devel@gmail.com> glcpp: Add GL_ARB_draw_instanced #define.
lcpp/glcpp-parse.y
919c53e87a1f6f5322bc1f1486bb3e6b954b00d5 08-Nov-2011 Eric Anholt <eric@anholt.net> mesa: Make gl_VertexID be a system value like gl_InstanceID.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltin_variables.cpp
44fc3c6c1c1072ee4ba2ad3b68ccb81086d71156 08-Nov-2011 Eric Anholt <eric@anholt.net> glsl: Move builtin_variables.h into .cpp.

This used to be script-generated, but now it's just a bunch of static
variables in a .h file for no good reason.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltin_variables.cpp
uiltin_variables.h
ab5c2622b6484df19db7e729f0e434a24dce2d10 08-Nov-2011 Eric Anholt <eric@anholt.net> glsl: Move ir_variable.cpp to builtin_variables.cpp.

It's only about builtins, not variables in general.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
akefile.sources
uiltin_variables.cpp
r_variable.cpp
a17a78a212be10fe3a9a330f3861d771e92d9074 09-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Handle constant expressions involving ir_binop_equal/nequal.

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 <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
r_constant_expression.cpp
83d0514f1fc5f747a4bf4c900338a47a17f86e4a 10-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove textureGradOffset built-ins taking samplerCube parameters.

These simply don't exist in the 1.30 specification---none of the Offset
variants allow samplerCube. This must have been a cut and paste error
from textureGrad, which /does/ allow cubemaps.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
uiltins/profiles/130.frag
uiltins/profiles/130.vert
uiltins/tools/texture_builtins.py
6a77f36ad9570c73b9a2a00302289832267eea99 10-Nov-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix misnamed textureProjOffset prototypes in built-in profiles.

Due to a cut and paste error, these were accidentally misnamed
textureProj() rather than textureProjOffset().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
uiltins/profiles/130.frag
uiltins/profiles/130.vert
2eb43bbb77f42b461632a622647874c22d7b9a5a 26-Oct-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove texture built-ins with 'bias' from 1.30 VS profile.

From the GLSL 1.30 spec, section 8.7 "Texture Lookup Functions":
"In all functions below, the bias parameter is optional for fragment
shaders. The bias parameter is not accepted in a vertex shader."

This was a cut and paste mistake.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
uiltins/profiles/130.vert
871ddb919b424293894a23a8f83200fed572d6a9 05-Nov-2011 Paul Berry <stereotype441@gmail.com> glsl: Assign transform feedback varying slots in linker.

This patch modifies the GLSL linker to assign additional slots for
varying variables used by transform feedback, and record the varying
slots used by transform feedback for use by the driver back-end.

This required modifying assign_varying_locations() so that it assigns
a varying location if either (a) the varying is used by the next stage
of the GL pipeline, or (b) the varying is required by transform
feedback. In order to avoid duplicating the code to assign a single
varying location, I moved it into its own function,
assign_varying_location().

In addition, to support transform feedback in the case where there is
no fragment shader, it is now possible to call
assign_varying_locations() with a consumer of NULL.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Marek Olšák <maraeo@gmail.com>
inker.cpp
6f5c73797087c6e7842665f84e41caedea59bb65 07-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Clamp vector indices when lowering to swizzles

This prevents other code from seeing a swizzle of the 16th component
of a vector, for example.

NOTE: This is a candidate for the 7.11 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42517
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Tested-by: Christian Holler <choller@mozilla.com>
ower_vec_index_to_swizzle.cpp
63e7a4c6e5bf51d8090046ebc5adcb4207448565 09-Nov-2011 José Fonseca <jfonseca@vmware.com> mesa,glsl,mapi: Put extern "C" { ... } where appropriate.

Probably a several places missing, but enough to cover all headers
(in)directly included by uniform_query.cpp, and fix the MSVC build.
lsl_types.h
r_uniform.h
fab88822735e7a8eeb0ce13ff13f90184e916f9f 08-Nov-2011 Brian Paul <brianp@vmware.com> glsl: remove trailing comma to silence warning
r_uniform.h
b12b5d9ab5c0153c93ca5ad9cd93cb36e41be4eb 05-Nov-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Use app-specified fragment data location during linking

Fixes piglit's bindfragdata-link-error.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
inker.cpp
5c02e2e2de75b9d18ca25b4f1cba38c4a89c5bd0 08-Nov-2011 Dan McCabe <zen3d.linux@gmail.com> glsl: Generate IR for switch statements

Up until now modifying the GLSL compiler has been pretty straightforward.
This is where things get interesting. But still pretty straightforward.

Switch statements can be thought of a series of if/then/else statements.
Case labels are compared with the value of a test expression and the case
statements are executed if the comparison is true.

There are a couple of aspects of switch statements that complicate this simple
view of the world. The primary one is that cases can fall through sequentially
to subsequent case, unless a break statement is encountered, in which case,
the switch statement exits completely.

But break handling is further complicated by the fact that a break statement
can impact the exit of a loop. Thus, we need to coordinate break processing
between switch statements and loop statements.

The code generated by a switch statement maintains three temporary state
variables:
int test_value;
bool is_fallthru;
bool is_break;

test_value is initialized to the value of the test expression at the head of
the switch statement. This is the value that case labels are compared against.

is_fallthru is used to sequentially fall through to subsequent cases and is
initialized to false. When a case label matches the test expression, this
state variable is set to true. It will also be forced to false if a break
statement has been encountered. This forcing to false on break MUST be
after every case test. In practice, we defer that forcing to immediately after
the last case comparison prior to executing a case statement, but that is
an optimization.

is_break is used to indicate that a break statement has been executed and is
initialized to false. When a break statement is encountered, it is set to true.
This state variable is then used to conditionally force is_fallthru to to false
to prevent subsequent case statements from executing.

Code generation for break statements depends on whether the break statement is
inside a switch statement or inside a loop statement. If it inside a loop
statement is inside a break statement, the same code as before gets generated.
But if a switch statement is inside a loop statement, code is emitted to set
the is_break state to true.

Just as ASTs for loop statements are managed in a stack-like
manner to handle nesting, we also add a bool to capture the innermost switch
or loop condition. Note that we still need to maintain a loop AST stack to
properly handle for-loop code generation on a continue statement. Technically,
we don't (yet) need a switch AST stack, but I am using one for orthogonality
with loop statements, in anticipation of future use. Note that a simple
boolean stack would have sufficed.

We will illustrate a switch statement with its analogous conditional code that
a switch statement corresponds to by examining an example.

Consider the following switch statement:
switch (42) {
case 0:
case 1:
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
case 2:
case 3:
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
break;
case 4:
default:
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

Note that case 0 and case 1 fall through to cases 2 and 3 if they occur.

Note that case 4 and the default case must be reached explicitly, since cases
2 and 3 break at the end of their case.

Finally, note that case 4 and the default case don't break but simply fall
through to the end of the switch.

For this code, the equivalent code can be expressed as:
int test_val = 42; // capture value of test expression
bool is_fallthru = false; // prevent initial fall through
bool is_break = false; // capture the execution of a break stmt

is_fallthru |= (test_val == 0); // enable fallthru on case 0
is_fallthru |= (test_val == 1); // enable fallthru on case 1
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
}

is_fallthru |= (test_val == 2); // enable fallthru on case 2
is_fallthru |= (test_val == 3); // enable fallthru on case 3
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
is_break = true; // inhibit all subsequent fallthru for break
}

is_fallthru |= (test_val == 4); // enable fallthru on case 4
is_fallthru = true; // enable fallthru for default case
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

The code generate for |= and &= uses the conditional assignment capabilities
of the IR.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
lsl_parser_extras.cpp
lsl_parser_extras.h
85beb39e14556cf02f58116fd287120cd1defbd5 08-Nov-2011 Dan McCabe <zen3d.linux@gmail.com> glsl: Reference data structure ctors in grammar

We now tie the grammar to the ctors of the ASTs they reference.

This requires that we actually have definitions of the ctors.

In addition, we also need to define "print" and "hir" methods for the AST
classes. The Print methods are pretty simple to flesh out. However, at this
stage of the development, we simply stub out the "hir" methods and flesh
them out later.

Also, since actual class instances get returned by the productions in the
grammar, we also need to designate the type of the productions that
reference those instances.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
lsl_parser.yy
lsl_parser_extras.cpp
a0afcc67196baa588ec0ac246be6c4996a328f0b 08-Nov-2011 Dan McCabe <zen3d.linux@gmail.com> glsl: Create AST structs corresponding to new productions in grammar

Previously we added productions for:
switch_body
case_label_list
case_statement
case_statement_list
Now add AST structs corresponding to those productions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st.h
80944599dcf070efa84ebf192c31f4129cee697d 08-Nov-2011 Dan McCabe <zen3d.linux@gmail.com> glsl: Add productions to GLSL grammar for switch statement

The grammar is modified to support switch statements. Rather than follow the
grammar in the appendix, which allows case labels to be placed ANYWHERE
as a regular statement, we follow the development of the grammar as
described in the body of the GLSL spec.

In this variation, the switch statement has a body which consists of a list
of case statements. A case statement is preceded by a list of case labels and
ends with a list of statements.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser.yy
19daba54707b4ff90159850ce97faceba9c336c0 08-Nov-2011 Dan McCabe <zen3d.linux@gmail.com> glsl: Create AST data structures for switch statement and case label

Data structures for switch statement and case label are created that parallel
the structure of other AST data.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st.h
be4524aeed7fb67bdc45861d299d4c5ca99c4d6c 19-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> Delete code made dead by previous uniform related patches

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
inker.cpp
719909698c67c287a393d2380278e7b7495ae018 19-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> mesa: Rewrite the way uniforms are tracked and handled

Switch all of the code in ir_to_mesa, st_glsl_to_tgsi, glUniform*,
glGetUniform, glGetUniformLocation, and glGetActiveUniforms to use the
gl_uniform_storage structures in the gl_shader_program.

A couple of notes:

* Like most rewrite-the-world patches, this should be reviewed by
applying the patch and examining the modified functions.

* This leaves a lot of dead code around in linker.cpp and
uniform_query.cpp. This will be deleted in the next patches.

v2: Update the comment block (previously a FINISHME) in _mesa_uniform
about generating GL_INVALID_VALUE when an out-of-range sampler index
is specified.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
inker.cpp
07731ed1692eb5d72110b3c5b693f37e581e3809 18-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Track uniform locations to new tracking structures

This is just the infrastructure and the code. It's not used yet.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
ink_uniforms.cpp
inker.h
466d5ffee4a370ba9d031c7bd685ed5d005479e9 18-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Add helper class for parcelling out backing storage to uniforms

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
ink_uniforms.cpp
57f79de6d0c428d15665801e4247675e97eae5e7 18-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Add helper class for determining uniform usage

v2: Remane class count_uniform_size based on feedback from Eric:

"Maybe just "count_uniform_size"? "usage" makes me think "way it's
dereferenced" or something."

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
ink_uniforms.cpp
4ad460991cb1f4d8904b075133af414a624a27f3 12-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add new structures for tracking uniforms in linked shaders

v2: Update some comments based on feedback from Eric Anholt.

v3: Remove gl_uniform_storage::dirty field. Make
gl_uniform_storage::initialized be bool, and make
gl_uniform_storage::sampler be uint8_t.

v4: Include stdbool.h after Tom Stellard noticed a build failure that
was introduced by the changes in v2. Oops.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
r_uniform.h
f6ee7bce65697ea3c6a78a000a49af901ba77c1d 12-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Make invalidate_variable_locations available outside the compilation unit

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
inker.cpp
inker.h
68db407b20e780d3f45b90b01f1271b7bd7e7a2b 12-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Allow glsl_types.h to be included in C sources

Some C code will want access to the glsl_base_type and
glsl_sampler_dim enums in the near future.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
lsl_types.h
f37b1ad937dd2c420f4c9fd9aa5887942bd31f3f 31-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Check that initializers for global variables match

This requires tracking a couple extra fields in ir_variable:

* A flag to indicate that a variable had an initializer.

* For non-const variables, a field to track the constant value of the
variable's initializer.

For variables non-constant initalizers, ir_variable::has_initializer
will be true, but ir_variable::constant_initializer will be NULL. The
linker can use the values of these fields to check adherence to the
GLSL 4.20 rules for shared global variables:

"If a shared global has multiple initializers, the initializers
must all be constant expressions, and they must all have the same
value. Otherwise, a link error will result. (A shared global
having only one initializer does not require that initializer to
be a constant expression.)"

Previous to 4.20 the GLSL spec simply said that initializers must have
the same value. In this case of non-constant initializers, this was
impossible to determine. As a result, no vendor actually implemented
that behavior. The 4.20 behavior matches the behavior of NVIDIA's
shipping implementations.

NOTE: This is candidate for the 7.11 branch. This patch also needs
the preceding patch "glsl: Refactor generate_ARB_draw_buffers_variables
to use add_builtin_constant"

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34687
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
st_to_hir.cpp
r.cpp
r.h
r_clone.cpp
r_validate.cpp
r_variable.cpp
inker.cpp
d3b39194dc60fa933f5e8df30bcd8d1cb64dbc4c 31-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Refactor generate_ARB_draw_buffers_variables to use add_builtin_constant

v2: Remove int cast based on feedback from Ken.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
r_variable.cpp
22af08b410f47227ea27b06cce097ccbe0130540 31-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Put all bitfields in ir_variable together for better packing

The diff looks weird because ir_variable::depth_layout was between the
last two bitfields in the structure.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
r.h
46173f907979af0b753befdcf6992e19d8453951 31-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Fix the indentation of a block in cross_validate_globals

I suspect the indentation got messed up during a code merge.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
inker.cpp
2903816aadb281716b6c59a5a48aeadb84a08f50 23-Oct-2011 Chia-I Wu <olv@lunarg.com> glsl: add support for GL_OES_EGL_image_external

This extension introduces a new sampler type: samplerExternalOES.
texture2D (and texture2DProj) can be used to do a texture look up in an
external texture.

Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st.h
st_type.cpp
uiltin_types.h
uiltins/profiles/OES_EGL_image_external.frag
uiltins/profiles/OES_EGL_image_external.vert
uiltins/tools/generate_builtins.py
uiltins/tools/texture_builtins.py
lcpp/glcpp-parse.y
lsl_lexer.ll
lsl_parser.yy
lsl_parser_extras.cpp
lsl_parser_extras.h
lsl_types.cpp
lsl_types.h
tandalone_scaffolding.cpp
9abda92b270596fd3a5e2e8b74e3fc3255da70ce 01-Nov-2011 Paul Berry <stereotype441@gmail.com> glsl: Fix type mismatch when incrementing or decrementing uint.

When converting an expression like "++x" to GLSL IR we were failing to
account for the possibility that x might be an unsigned integral type.
As a result the user would receive a bogus error message "Could not
implicitly convert operands to arithmetic operator".

Fixes piglit tests {vs,fs}-{increment,decrement}-uint.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
45568faba25c503b59018b8b414f5751c83b1d88 30-Oct-2011 Chia-I Wu <olvaffe@gmail.com> scons: include src/glsl/Makefile.sources

Reviewed-by: Brian Paul <brianp@vmware.com>
Conscript
fb0e4a23fab6992e827f0b62d5326745065074a2 30-Oct-2011 Chia-I Wu <olvaffe@gmail.com> android: include src/glsl/Makefile.sources

This also fixes the build error due to missing link_uniforms.cpp in the source
lists.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Chad Versace <chad@chad-versace.us>

[olv: the missing link_uniforms.cpp was added before this patch is committed]
ndroid.mk
dfdb34b7c1ad38027c301ac71d3890c6c5d5751a 30-Oct-2011 Chia-I Wu <olvaffe@gmail.com> glsl: Refactor source lists to Makefile.sources

With the hope that Android.mk and SConscript can share the file to reduce
future breakage.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Chad Versace <chad@chad-versace.us>
akefile
akefile.sources
48a4b9b70cd0020ad09d605672a53dd7be86b3af 01-Nov-2011 Eugeni Dodonov <eugeni.dodonov@intel.com> Build link_uniforms for android

Otherwise android-x86 build fails.

Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
ndroid.mk
7f08248c2e2d7e862e88db2d0008efca3c276512 01-Nov-2011 José Fonseca <jose.r.fonseca@gmail.com> ralloc: Use _vscprintf on MinGW.

MinGW uses MSVC's runtime DLLs for most of C runtime's functions, and
there has same semantics for vsnprintf.

Not sure how this worked until now -- maybe one of the internal
vsnprintf implementations was taking precedence.
alloc.c
fa0066ae2b2d304065ee8d93d9b5ecc8b457425a 26-Oct-2011 Paul Berry <stereotype441@gmail.com> mesa: Add glsl_type::get_scalar_type() function.

This function is similar to get_base_type(), but when called on
arrays, it returns the scalar type composing the array. For example,
glsl_type(vec4[]) => float_type.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_types.cpp
lsl_types.h
ede60bc4670a8d9c14921c77abee1ac57fc0e6bf 06-Oct-2011 Paul Berry <stereotype441@gmail.com> glsl: Add isinf() and isnan() builtins.

The implementations are as follows:

isinf(x) = (abs(x) == +infinity)
isnan(x) = (x != x)

Note: the latter formula is not necessarily obvious. It works because
NaN is the only floating point number that does not equal itself.

Fixes piglit tests "isinf-and-isnan fs_basic" and "isinf-and-isnan
vs_basic".
uiltins/ir/isinf.ir
uiltins/ir/isnan.ir
uiltins/profiles/130.frag
uiltins/profiles/130.vert
b6f32bbe12e1082e78951b6ef073bf244ba0b8b7 06-Oct-2011 Paul Berry <stereotype441@gmail.com> glsl: Add '.ir' extension to builtin IR files

This patch adds the extension '.ir' to all the files in
src/glsl/builtins/ir/, and changes generate_builtins.py so that it no
longer globs on '*' to find the files to build. This prevents
spurious files (such as EMACS' infamous *~ backup files) from breaking
the build.
uiltins/ir/abs
uiltins/ir/abs.ir
uiltins/ir/acos
uiltins/ir/acos.ir
uiltins/ir/acosh
uiltins/ir/acosh.ir
uiltins/ir/all
uiltins/ir/all.ir
uiltins/ir/any
uiltins/ir/any.ir
uiltins/ir/asin
uiltins/ir/asin.ir
uiltins/ir/asinh
uiltins/ir/asinh.ir
uiltins/ir/atan
uiltins/ir/atan.ir
uiltins/ir/atanh
uiltins/ir/atanh.ir
uiltins/ir/ceil
uiltins/ir/ceil.ir
uiltins/ir/clamp
uiltins/ir/clamp.ir
uiltins/ir/cos
uiltins/ir/cos.ir
uiltins/ir/cosh
uiltins/ir/cosh.ir
uiltins/ir/cross
uiltins/ir/cross.ir
uiltins/ir/dFdx
uiltins/ir/dFdx.ir
uiltins/ir/dFdy
uiltins/ir/dFdy.ir
uiltins/ir/degrees
uiltins/ir/degrees.ir
uiltins/ir/distance
uiltins/ir/distance.ir
uiltins/ir/dot
uiltins/ir/dot.ir
uiltins/ir/equal
uiltins/ir/equal.ir
uiltins/ir/exp
uiltins/ir/exp.ir
uiltins/ir/exp2
uiltins/ir/exp2.ir
uiltins/ir/faceforward
uiltins/ir/faceforward.ir
uiltins/ir/floor
uiltins/ir/floor.ir
uiltins/ir/fract
uiltins/ir/fract.ir
uiltins/ir/ftransform
uiltins/ir/ftransform.ir
uiltins/ir/fwidth
uiltins/ir/fwidth.ir
uiltins/ir/greaterThan
uiltins/ir/greaterThan.ir
uiltins/ir/greaterThanEqual
uiltins/ir/greaterThanEqual.ir
uiltins/ir/inversesqrt
uiltins/ir/inversesqrt.ir
uiltins/ir/length
uiltins/ir/length.ir
uiltins/ir/lessThan
uiltins/ir/lessThan.ir
uiltins/ir/lessThanEqual
uiltins/ir/lessThanEqual.ir
uiltins/ir/log
uiltins/ir/log.ir
uiltins/ir/log2
uiltins/ir/log2.ir
uiltins/ir/matrixCompMult
uiltins/ir/matrixCompMult.ir
uiltins/ir/max
uiltins/ir/max.ir
uiltins/ir/min
uiltins/ir/min.ir
uiltins/ir/mix
uiltins/ir/mix.ir
uiltins/ir/mod
uiltins/ir/mod.ir
uiltins/ir/modf
uiltins/ir/modf.ir
uiltins/ir/noise1
uiltins/ir/noise1.ir
uiltins/ir/noise2
uiltins/ir/noise2.ir
uiltins/ir/noise3
uiltins/ir/noise3.ir
uiltins/ir/noise4
uiltins/ir/noise4.ir
uiltins/ir/normalize
uiltins/ir/normalize.ir
uiltins/ir/not
uiltins/ir/not.ir
uiltins/ir/notEqual
uiltins/ir/notEqual.ir
uiltins/ir/outerProduct
uiltins/ir/outerProduct.ir
uiltins/ir/pow
uiltins/ir/pow.ir
uiltins/ir/radians
uiltins/ir/radians.ir
uiltins/ir/reflect
uiltins/ir/reflect.ir
uiltins/ir/refract
uiltins/ir/refract.ir
uiltins/ir/round
uiltins/ir/round.ir
uiltins/ir/roundEven
uiltins/ir/roundEven.ir
uiltins/ir/sign
uiltins/ir/sign.ir
uiltins/ir/sin
uiltins/ir/sin.ir
uiltins/ir/sinh
uiltins/ir/sinh.ir
uiltins/ir/smoothstep
uiltins/ir/smoothstep.ir
uiltins/ir/sqrt
uiltins/ir/sqrt.ir
uiltins/ir/step
uiltins/ir/step.ir
uiltins/ir/tan
uiltins/ir/tan.ir
uiltins/ir/tanh
uiltins/ir/tanh.ir
uiltins/ir/transpose
uiltins/ir/transpose.ir
uiltins/ir/trunc
uiltins/ir/trunc.ir
uiltins/tools/generate_builtins.py
b726639e1be0614fb6bbb75a6f07c63eacc6d787 06-Oct-2011 Paul Berry <stereotype441@gmail.com> glsl: Fix copy-paste error in constant_expression_value(ir_binop_nequal)

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.
r_constant_expression.cpp
439d67f502cf78a977501c310e13d8d5f05e4986 29-Oct-2011 Morgan Armand <morgan.devel@gmail.com> glsl: Fix compilation of glsl_lexer.ll with MSVC.

strtoull is not supported on msvc (as there is no C99 support).
lsl_lexer.ll
f5ba4d055ee27bfd741ad019e3b3d4b1a1ce9bd9 26-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Clean-up spurious error message on bad structure definitions

Previously a shader like

int X;
struct X { int i; };

void main() { gl_Position = vec4(0.0); }

would generate two error message:

0:2(19): error: struct `X' previously defined
0:2(20): error: incomplete declaration

The first one is the real error, and the second is spurious.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
a04211ecb8c907eaef69832abc2e16cd6f9887a0 24-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Generate an error for array-of-array declarations

Other parts of the code already caught things like 'float x[4][2]'.
However, nothing caught 'float [4] x[2]'.

Fixes piglit test array-multidimensional-new-syntax.vert.

NOTE: This is candidate for the 7.11 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
687e4446bf5c5d3bc4a56ad4e9291a9cf2a2958c 04-Oct-2011 Eric Anholt <eric@anholt.net> glsl: Implement GLSL 1.30's literal integer range restrictions.

From page 22 (28 of PDF) of GLSL 1.30 spec:
It is an error to provide a literal integer whose magnitude is too
large to store in a variable of matching signed or unsigned type.

Unsigned integers have exactly 32 bits of precision. Signed integers
use 32 bits, including a sign bit, in two's complement form.

Fixes piglit int-literal-too-large-0[123].frag.

v2: Take care with INT_MIN, use stroull, and make it a function.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_lexer.ll
3b4d2eac6001b464df11b175bd14fd4d3c4e412f 25-Oct-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove pointless uses of glsl_type::get_base_type().

These are effectively doing type->get_base_type()->base_type, which is
equivalent to type->base_type. Just use that, as it's simpler.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_print_visitor.cpp
r_reader.cpp
baf7f99fd7a092a1390b7a145e09caa5325a8116 21-Oct-2011 Paul Berry <stereotype441@gmail.com> glsl: add ir_variable::determine_interpolation_mode() function.

This function determines how a variable should be interpolated based
both on interpolation qualifiers and the current shade model.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.cpp
r.h
c488150dea083a9677429b4185c6b20d7facd52b 21-Oct-2011 Paul Berry <stereotype441@gmail.com> glsl: Distinguish between no interpolation qualifier and 'smooth'

Previously, we treated the 'smooth' qualifier as equivalent to no
qualifier at all. However, this is incorrect for the built-in color
variables (gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor, and
gl_BackSecondaryColor). For those variables, if there is no qualifier
at all, interpolation should be flat if the shade model is GL_FLAT,
and smooth if the shade model is GL_SMOOTH.

To make this possible, I added a new value to the
glsl_interp_qualifier enum, INTERP_QUALIFIER_NONE.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
st_to_hir.cpp
r.cpp
r.h
cf45949d6a896651a5f3864d3b195e26d59eee74 26-Oct-2011 Paul Berry <stereotype441@gmail.com> mesa: Expose GLSL interpolation qualifiers in gl_fragment_program.

This patch makes GLSL interpolation qualifiers visible to drivers via
the array InterpQualifier[] in gl_fragment_program, so that they can
easily be used by driver back-ends to select the correct interpolation
mode.

Previous to this patch, the GLSL compiler was using the enum
ir_variable_interpolation to represent interpolation types. Rather
than make a duplicate enum in core mesa to represent the same thing, I
moved the enum into mtypes.h and renamed it to be more consistent with
the other enums defined there.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
st_to_hir.cpp
r.cpp
r.h
r_reader.cpp
r_set_program_inouts.cpp
4fc9a98a0e01195202cd5f3f5a78cf28c5e8843c 21-Oct-2011 Eric Anholt <eric@anholt.net> glsl: Rename remaining internal builtins from gl_MESA* to gl_*MESA.

This matches the usual convention for extension builtin variables.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltin_variables.h
r_variable.cpp
20a20c781ac2143e92807fa8dfab086a5b7c1d53 26-Oct-2011 Vinson Lee <vlee@vmware.com> ralloc: Move declaration before code.

Fixes build error with MSVC.
alloc.c
a936b206a01301d8c76fc1ddcb4d4550f8595b31 26-Oct-2011 Vinson Lee <vlee@vmware.com> scons: Add link_uniforms.cpp to SConscript.
Conscript
747e59c7590bd11a4964c6ca12c5ff0dbb6282f2 25-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Add uniform_field_visitor class to process leaf fields of a uniform

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
ink_uniforms.cpp
inker.h
ca95593d49a2d99a16c160c2a04acc4be007d8a4 25-Oct-2011 Kenneth Graunke <kenneth@whitecape.org> ralloc: Add new [v]asprintf_rewrite_tail functions.

This can be useful if you want to create a bunch of temporary strings
with a common prefix. For example, when iterating over uniform
structure fields, one might want to create temporary strings like
"pallete.primary", "palette.outline", and "pallette.shadow".

This could be done by overwriting the '.' with a null-byte and calling
ralloc_asprintf_append, but that incurs the cost of strlen("pallete")
every time...when this is already known.

These new functions allow you rewrite the tail of the string, given a
starting index. If the starting index is the length of the string, this
is equivalent to appending.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
alloc.c
alloc.h
960d722bf7db636863a05ddf9258236fccb58ecd 21-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Eliminate more dead code after demoting shader inputs and outputs

Consider the following vertex shader and fragment shader:

// vertex shader
varying vec4 v;
uniform vec4 u;

void main() { gl_Position = vec4(0.0); v = u; }

// fragment shader
void main() { gl_FragColor = vec4(0.0); }

Since the fragment shader does not use 'v', it is demoted from a
varying to a simple global variable. Once that happens, the
assignment to 'v' is useless, and it should be removed. In addition,
'u' is no longer active, and it should also be removed.

Performing extra dead code elimination after demoting shader inputs
and outputs takes care of this. This elimination must occur before
assigning uniform locations, or the declaration of 'u' cannot be
removed.

This change *breaks* the piglit test getuniform-01, but that test is
already incorrect. The test uses a vertex shader that assigns to a
user-defined varying, but it has no fragment shader. Since Mesa does
not support ARB_separate_shader_objects (we only support the EXT
version), the linker correctly eliminates the user-defined varying.
The cascading effect is that the uniform queried by the C code of the
test is also (correctly) eliminated.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41980
Tested-by: Brian Paul <brianp@vmware.com>
Cc: Bryan Cain <bryancain3@gmail.com>
Cc: Vinson Lee <vlee@vmware.com>
Cc: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
inker.cpp
1d5d67f8adac9f94715de9804adb536d9a7ec5ee 21-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add uniform_locations_assigned parameter to do_dead_code opt pass

Setting this flag prevents declarations of uniforms from being removed
from the IR. Since the IR is directly used by several API functions
that query uniforms in shaders, uniform declarations cannot be removed
after the locations have been set. However, it should still be safe
to reorder the declarations (this is not tested).

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41980
Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Bryan Cain <bryancain3@gmail.com>
Cc: Vinson Lee <vlee@vmware.com>
Cc: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lsl_parser_extras.cpp
r_optimization.h
inker.cpp
ain.cpp
pt_dead_code.cpp
est_optpass.cpp
cc4ddc3a1e4bbe5fccd03b39b3590368be8c172f 19-Oct-2011 Eric Anholt <eric@anholt.net> glsl: Fix gl_NormalMatrix swizzle setup to match i965's invariants.

A driver trying to set up builtin uniforms is faced with a problem:
How do I walk the ir_variable structure (representing an array of
structs, or array of matrices, or struct, or whatever), and set up
driver structures so that dereference of that uniform gets the
corresponding ParameterValues[] entry. The rule in general is that
each corresponding vector-sized field of an array of structs is one
builtin uniform state slot. i965 relied on another invariant: each
state slot has a number of unique channel swizzles corresponding to
the number of elements in the field's vector, to avoid needing to walk
the glsl_type in parallel to get at vector_elements.

All of the builtin uniforms followed this behavior, except for
gl_NormalMatrix. That's a mat3 (so 3 vec3s), but it was swizzled as 3
vec4s.

Fixes piglit glsl-fs-normalmatrix.
Reviewed-by: Paul Berry <stereotype441@gmail.com>
r_variable.cpp
2ecfa88548c6b3135101ae9b5a2ae83b1cef8784 22-Oct-2011 Eric Anholt <eric@anholt.net> glsl: Add gl_MaxVaryingComponents in GLSL 1.30.

This is the new name for gl_MaxVaryingFloats now that non-float
varyings exist. Fixes piglit
glsl-1.30/execution/maximums/gl_MaxVaryingFloats

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_variable.cpp
dc637b66b25f341783efb53acc70e1bafbcba576 27-Sep-2011 Eric Anholt <eric@anholt.net> glsl: Add support for constant expression evaluation on round(), roundEven().

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 <kenneth@whitecape.org>
r_constant_expression.cpp
1595c79d9c60d8cc03763e64285b691d6748be95 19-Oct-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Short-circuit lower_if_to_cond_assign when MaxIfDepth is UINT_MAX.

Setting MaxIfDepth to UINT_MAX effectively means "don't lower anything."

Explicitly checking for this common case allows us to avoid walking the
IR, computing nesting levels, and so on.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Bryan Cain <bryancain3@gmail.com>
ower_if_to_cond_assign.cpp
bbbb8345ab9df2d634dc2a34d257ee2cbf930292 11-Sep-2011 Ian Romanick <ian.d.romanick@intel.com> ir_to_mesa: Move some things outside the 'extern "C"' blocks

Having a few of these includes or forward declarations inside the
'extern "C"' block can cause problems later. Specifically, it
prevents C++ linkage functions from being added to ir_to_mesa.h and
makes G++ angry if 'struct foo' is seen both inside and outside an
'extern "C"'.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_clone.cpp
r_print_visitor.cpp
r_set_program_inouts.cpp
3c22e3516527ccb83f2667abfa0e6518c5938df8 23-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Stop tree grafting if a variable is overwritten as an 'out' param.

While reviewing some compiler cleanups I'd sent out, Paul noticed that
tree grafting wasn't taking "out" parameters into account.

Further investigation revealed that it isn't strictly necessary: ir_call
ends basic blocks, and tree grafting currently only operates on basic
blocks. So calls already kill grafts.

However, just to be safe, this patch makes "out" parameters explicitly
kill grafts. Paul and I both prefer this. It's a bit clearer.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
pt_tree_grafting.cpp
57f7978b1de40be6eb138d391c8d9f95b68cbf62 22-Jul-2011 Eric Anholt <eric@anholt.net> mesa: Add a flag for shader programs to allow SSO linkage in GLES2.

On converting fixed function programs to generate GLSL, the linker
became cranky that we were trying to make something that wasn't a
linked vertex+fragment program. Given that the Mesa GLES2 drivers
also support desktop GL with EXT_sso, just telling the linker to shut
up seems like the easiest solution.
inker.cpp
f868cb09639d69acbc900842263ac2d28b60bcc0 17-Jul-2011 Eric Anholt <eric@anholt.net> glsl: Add gl_CurrentAttrib{Vert,Frag}MESA internal builtin uniforms.

These will be used by the FF VS/FS to represent the current attributes
when they don't have an active vertex array.
r_variable.cpp
9f0e98d1dfcf83a07a62e9c62e3dc77336789b4a 06-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Fix a slightly incorrect comment

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
93c26d8baf5294b77e019b90d9995b5da565ea3c 07-Sep-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Remove unused method ir_variable::component_slots

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
r.h
c475a54578bf5473c6c62bc5468ef4fe555164d7 07-Oct-2011 Jason Wood <sandain@hotmail.com> glsl: Remove version check when looking for identifiers containing "__".

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
684b701c124cf258ba9012adf51357e072ae61f9 04-Oct-2011 Eric Anholt <eric@anholt.net> glsl: Consider "__" in identifers as reserved.

Fixes double-underscore-*.frag.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
7d68c639ddb0f9df45cf698b8e8227bf1860b5fe 26-Sep-2011 Paul Berry <stereotype441@gmail.com> mesa: Add a gl_vert_result for gl_ClipVertex.

Before this patch, clip planes didn't work properly in Mesa when using
vertex shaders, because Mesa assigned both gl_ClipVertex and
gl_Position to the same gl_vert_result (VERT_RESULT_HPOS). As a
result, backends couldn't distinguish between the two variables, so
any shader that wrote different values to them would fail to work
properly.

This patch paves the way for proper support of gl_ClipVertex by
creating a new enumerated value in gl_vert_result for it
(VERT_RESULT_CLIP_VERTEX). After this patch, a back-end may add
support for gl_ClipVertex using the following algorithm:

- If using a user-supplied GLSL vertex shader:
- If the bit corresponding to VERT_RESULT_CLIP_VERTEX is set in
gl_program::OutputsWritten:
- Clip using the vertex shader output VERT_RESULT_CLIP_VERTEX and
the clip planes defined in gl_context::Transform.EyeUserPlane.
- Else:
- Clip using the vertex shader output VERT_RESULT_HPOS and the
clip planes defined in gl_context::Transform.EyeUserPlane.
- Else (either using fixed function or an ARB vertex program):
- Clip using the vertex shader output VERT_RESULT_HPOS and the clip
planes defined in gl_context::Transform._ClipUserPlane (*)

where (*) represents the normal Mesa behavior before this patch.

An example of implementing the above algorithm can be found in the
patch that follows this one, which implements gl_ClipVertex in i965
Gen6.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltin_variables.h
af962e11830db02f4f33a69219155d1ddb7c04d0 05-Oct-2011 Stéphane Marchesin <marcheu@chromium.org> glsl: Remove unneeded headers.
r_validate.cpp
pt_function_inlining.cpp
523b611646ae15aa05ed37597ae9162de7290faf 18-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Use gl_shader_program::AttributeBindings for attrib locations

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
7bbcc0b832b02f9da6365ec6a86a0167cf75d8a8 30-Sep-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Delete symbol table in post-link shaders

The symbol table in the linked shaders may contain references to
variables that were removed (e.g., unused uniforms). Since it may
contain junk, there is no possible valid use. Delete it and set the
pointer to NULL.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
763b00f2c596e167299e81684763b52422956dfc 03-Oct-2011 Ian Romanick <ian.d.romanick@intel.com> mesa: Remove ARB_draw_buffers extension enable flag

All drivers in Mesa have supported this extension for eons. This
extension is an optional features in desktop OpenGL (via
GL_ARB_draw_buffers) and OpenGL ES 2.x (via GL_NV_draw_buffers).

The extension is not usable in OpenGL ES 1.x. There is no
glDrawBuffers* entry point in OpenGL ES 1.x contexts, and glGet*v
generate errors when MAX_DRAW_BUFFERS or DRAW_BUFFERi is queried.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
tandalone_scaffolding.cpp
201485bae0fcba4db61ceb1e9d9916778b5bba74 30-Sep-2011 Carl Worth <cworth@cworth.org> glcpp: Add a test for #elif with an undefined macro.

As written, this test correctly raises an error for #elif being used
with an undefined macro (and not as an argument to "defined"). If the
preceding #if were '#if 1' then this diagnositc would correctly be
hidden. That allows code such as the following to not raise an error:

#ifndef MAYBE_UNDEFINED
#elif MAYBE_UNDEFINED < 5
...
#endif

So this test case is working as expected already. We add it here just
to improve test coverage.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
lcpp/tests/098-elif-undefined.c
lcpp/tests/098-elif-undefined.c.expected
c4aaf7943c2cdff0e2148b5c05813356dc99696d 30-Sep-2011 Carl Worth <cworth@cworth.org> glcpp: Raise error if defining any macro containing two consecutive underscores

The specification reserves any macro name containing two consecutive
underscores, (anywhere within the name). Previously, we only raised
this error for macro names that started with two underscores.

Fix the implementation to check for two underscores anywhere, and also
update the corresponding 086-reserved-macro-names test.

This also fixes the following two piglit tests:

spec/glsl-1.30/preprocessor/reserved/double-underscore-02.frag
spec/glsl-1.30/preprocessor/reserved/double-underscore-03.frag

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Carl Worth <cworth@cworth.org>
lcpp/glcpp-parse.y
lcpp/tests/086-reserved-macro-names.c
lcpp/tests/086-reserved-macro-names.c.expected
28842c2331e6df2cbe18c0be3487ece93680075d 30-Sep-2011 Carl Worth <cworth@cworth.org> glcpp: Implement token pasting for non-function-like macros

This is as simple as abstracting one existing block of code into a
function call and then adding a single call to that function for the
case of a non-function-like macro.

This fixes the recently-added 097-paste-with-non-function-macro test
as well as the following piglit tests:

spec/glsl-1.30/preprocessor/concat/concat-01.frag
spec/glsl-1.30/preprocessor/concat/concat-02.frag

Also, the concat-04.frag test now passes for the right reason. The
test is intended to fail the compilation, but before this commit it
was failing compilation (and hence passing the test) for the wrong
reason.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
lcpp/glcpp-parse.y
7bb3403e0172a440b8100bcf1db8462f50a254cc 30-Sep-2011 Carl Worth <cworth@cworth.org> glcpp: Test a non-function-like macro using the token paste operator

Apparently we never implemented this, (but we've got a GLSL 1.30 test
in piglit that is exercising this case).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
lcpp/tests/097-paste-with-non-function-macro.c
lcpp/tests/097-paste-with-non-function-macro.c.expected
3c01a589448b92945f26bd7e3bfa75155c06f3cf 30-Sep-2011 Carl Worth <cworth@cworth.org> glcpp: Fix two (or more) successive applications of token pasting

There was already a loop here to look for multiple token pastes, but
it was mistakenly incrementing the iterator counter after performing
one paste.

Instead, leave the loop iterator in place to coalesce as many tokens
as necessary into one.

This fixes the recently add 096-paste-twice test as well as the
following piglit test:

spec/glsl-1.30/preprocessor/concat/concat-03.frag

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
lcpp/glcpp-parse.y
8e6b99e7b13da33547fcc8388fe867e851ee0bda 30-Sep-2011 Carl Worth <cworth@cworth.org> glcpp: Add a test for a macro that implements token pasting twice.

This is something that piglit is exercising that currently fails.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
lcpp/tests/096-paste-twice.c
lcpp/tests/096-paste-twice.c.expected
9c7552729971463af015a767e547c43f94fe1212 27-Sep-2011 Paul Berry <stereotype441@gmail.com> glsl 1.30: Fix numerical instabilities in asinh

The formula we were previously using for asinh:

asinh x = ln(x + sqrt(x * x + 1))

is numerically unstable: when x is a large negative value, the quantity

x + sqrt(x * x + 1)

is a small positive value (on the order of 1/(2|x|)). Since the
logarithm function is very sensitive in this range, any error in the
computation of the square root manifests as a large error in the
result.

This patch changes to the equivalent formula:

asinh x = sign(x) * ln(abs(x) + sqrt(x * x + 1))

which is only slightly more expensive to compute, and is numerically
stable for all x.

Fixes piglit tests
spec/glsl-1.30/execution/built-in-functions/[fv]s-asinh-*.

Reviewed-by: Chad Versace <chad@chad-versace.us>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
uiltins/ir/asinh
9f220bd1353b3d141d6a0308103ff403d8653e23 27-Sep-2011 Eric Anholt <eric@anholt.net> glsl: Add support for constant expression evaluation on trunc().

Fixes the glsl-1.30/compiler/built-in-functions/trunc-* tests under 1.30.

Reviewed-by: Chad Versace <chad@chad-versace.us>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_constant_expression.cpp
344f94bb006188931b09939aafc7cc96609c4f5a 27-Sep-2011 Eric Anholt <eric@anholt.net> glsl: Fix assertion checking types of constant bitshift expressions.

Bitshifts are one of the rare places that GLSL allows mixed base types
without an implicit conversion occurring.

Reviewed-by: Chad Versace <chad@chad-versace.us>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_constant_expression.cpp
06ae4a62b1b3c668a5b50661df25d87f8c2679ef 25-Sep-2011 Chad Versace <chad@chad-versace.us> glsl: Fix Android build

Add lower_clip_distance.cpp to list of source files.

Signed-off-by: Chad Versace <chad@chad-versace.us>
ndroid.mk
0d949a51bb44da51cd843abcf6ecddc5e3d3a2f1 22-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Free all S-Expressions immediately after reading IR.

For some reason I thought subexpressions were chained off the top-level
one. This isn't the case, so just create a temporary context and free
it. All of this memory would be eventually freed, but now is freed
much sooner.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
r_reader.cpp
0fabf8e8dc96a0eb8a9fbbac760d4faceee3af48 20-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Defer initialization of built-in functions until they're needed.

Very simple shaders don't actually use GLSL built-ins. For example:
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_FragColor = vec4(0.0);
Both of the shaders used by _mesa_meta_glsl_Clear() also qualify.

By waiting to initialize the built-ins until the first time we need to
look for a signature, we can avoid the overhead entirely in these cases.

Makes piglit run roughly 18% faster (255 vs. 312 seconds).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
st_function.cpp
st_to_hir.cpp
uiltins/tools/generate_builtins.py
lsl_parser_extras.cpp
3d7c5a4f6f4155e249f6eac76d861eb1bc59eb69 19-Aug-2011 Paul Berry <stereotype441@gmail.com> mesa: set up gl_vert_result and gl_frag_attrib values for gl_ClipDistance.

This patch assigns enumerated values for gl_ClipDistance in the
gl_vert_result and gl_frag_attrib enums, so that driver back-ends can
assign gl_ClipDistance to the appropriate hardware registers. It also
adjusts the functions _mesa_vert_result_to_frag_attrib() and
_mesa_frag_attrib_to_vert_result() (which translate between the two
enums) to correctly translate the new enumerated values.

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Brian Paul <brianp@vmware.com>
r_variable.cpp
1ad54ae0b1713e399c5db43d0eba87861075b4c7 17-Sep-2011 Paul Berry <stereotype441@gmail.com> mesa: Add a flag to indicate whether a program uses gl_ClipDistance.

GLSL 1.30 requires us to use gl_ClipDistance for clipping if the
vertex shader contains a static write to it, and otherwise use
user-defined clipping planes. Since the driver needs to behave
differently in these two cases, we need a flag to record whether the
shader has written to gl_ClipDistance.

The new flag is called UsesClipDistance. We initially store it in
gl_shader_program (since that is the data structure that is available
when we check to see whethe gl_ClipDistance was written to), and we
later copy it to a flag with the same name in gl_vertex_program, since
that is a more convenient place for the driver to access it (in i965,
at least).

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Brian Paul <brianp@vmware.com>
inker.cpp
c06e32596735074536b0e613cbddb1c5fd7b367a 12-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Implement a lowering pass for gl_ClipDistance.

In i965 GEN6+ (and I suspect most other hardware), gl_ClipDistance
needs to be laid out as a pair of vec4's (the first containing clip
distances 0-3, and the second containing clip distances 4-7).
However, it is declared in GLSL as an array of 8 floats.

This lowering pass acts at the GLSL level, modifying the declaration
of gl_ClipDistance so that it is an array of vec4's rather than an
array of floats, and renaming it to gl_ClipDistanceMESA. In addition,
it modifies all accesses to the array so that they access the
appropiate component of one of the vec4's.

Since some hardware may not internally represent gl_ClipDistance as a
pair of vec4's, this lowering pass is optional. To enable it, set the
LowerClipDistance flag in gl_shader_compiler_options to true.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
Conscript
r_optimization.h
inker.cpp
ower_clip_distance.cpp
cc81eb09b928389f926b3512c18b3298777d2928 19-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl hierarchical visitor: Do not overwrite base_ir for parameter lists.

This patch fixes a bug in ir_hirearchical_visitor: when traversing an
exec_list representing the formal or actual parameters of a function,
it modified base_ir to point to each parameter in turn, rather than
leaving it as a pointer to the enclosing statement. This was a
problem, since base_ir is used by visitor classes to locate the
statement containing the node being visited (usually so that
additional statements can be inserted before or after it). Without
this fix, visitors might attempt to insert statements into parameter
lists.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_hierarchical_visitor.h
r_hv_accept.cpp
dbae4960831d319ff2f536d88dc3104d9e031dfa 20-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> make: Don't use builtin_stubs.cpp for standalone GLSL compiler.

builtin_stubs.cpp is only supposed to be used for builtin_compiler. It
contains a stub version of _mesa_glsl_initialize_functions() that does
nothing.

libglsl.a already contains builtin_function.cpp, the generated file that
contains a version of _mesa_glsl_initialize_functions() that actually
initializes all the built-in functions.

By mistakenly linking to builtin_stubs, glsl_compiler and glsl_test are
unable to compile any shaders that use built-in functions.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
akefile
00792e3586746c833ffc9bb65712e38038916e06 10-Sep-2011 Paul Berry <stereotype441@gmail.com> glsl: Remove field array_lvalue from ir_variable.

The array_lvalue field was attempting to enforce the restriction that
whole arrays can't be used on the left-hand side of an assignment in
GLSL 1.10 or GLSL ES, and can't be used as out or inout parameters in
GLSL 1.10.

However, it was buggy (it didn't work properly for built-in arrays),
and it was clumsy (it unnecessarily kept track on a
variable-by-variable basis, and it didn't cover the GLSL ES case).

This patch removes the array_lvalue field completely in favor of
explicit checks in ast_parameter_declarator::hir() (this check is
added) and in do_assignment (this check was already present).

This causes a benign behavioral change: when the user attempts to pass
an array as an out or inout parameter of a function in GLSL 1.10, the
error is now flagged at the time the function definition is
encountered, rather than at the time of invocation. Previously we
allowed such functions to be defined, and only flagged the error if
they were invoked.

Fixes Piglit tests
spec/glsl-1.10/compiler/qualifiers/fn-{out,inout}-array-prohibited*
and
spec/glsl-1.20/compiler/assignment-operators/assign-builtin-array-allowed.vert.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
r.cpp
r.h
r_clone.cpp
f0dd21ac88c0ee0a7dd96012881deeb3172974b6 22-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Silence "ast_to_hir.cpp:1984:25: warning: comparison of unsigned expression >= 0 is always true"

ast_type_qualifier::location should have been a signed integer from
the beginning, and the giant comment in
apply_type_qualifier_to_variable explains why.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40207
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st.h
9a3bd5e0452c9c791ba94155d3c9ddba42abd114 29-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Silence several "warning: unused parameter"
st_to_hir.cpp
uiltin_stubs.cpp
lcpp/glcpp.c
r_function_detect_recursion.cpp
ower_jumps.cpp
pt_discard_simplification.cpp
pt_if_simplification.cpp
tandalone_scaffolding.cpp
60df737ad57c20701b66d7cd3f63d1dc75745986 07-Sep-2011 Eric Anholt <eric@anholt.net> glsl: Don't do structure splitting until link time.

We were splitting on each side of an unlinked program, and the two
sides lost track of which variables they referenced, resulting in
assertion failure during validation. Fixes piglit
link-struct-uniform-usage.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.cpp
525cec98a5c65c27c62fed0cff706bca50bf8c6e 07-Sep-2011 Eric Anholt <eric@anholt.net> glsl: Clarify error message about whole-array assignment in GLSL 1.10.

Previously, it would produce:

Failed to compile FS: 0:6(7): error: non-lvalue in assignment

and now it produces:

Failed to compile FS: 0:5(7): error: whole array assignment is not
allowed in GLSL 1.10 or GLSL ES 1.00.

Also, add spec quotation to the two places we have code for array
lvalues in GLSL 1.10.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
407a1001aefcb15e8d066031417d91ea22f1daf1 07-Sep-2011 Eric Anholt <eric@anholt.net> glsl: When assiging from a whole array, mark it as used.

Fixes piglit link-uniform-array-size.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
d00deae3ef3a7828de1e566ad95b3a5b1ab7034d 07-Sep-2011 Eric Anholt <eric@anholt.net> glsl: Fix setting of OutputsWritten for whole array dereference.

We just want to mark the whole thing used, not mark from each element
the whole size in use. Fixes undefined URB entry writes on i965,
which blew up with debugging enabled.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_set_program_inouts.cpp
b453ba2c9f8ccb1d61a0ef50f0a40592df3366c3 12-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Make sure gl_ClipDistance and gl_ClipVertex are not both written.

From section 7.1 (Vertex Shader Special Variables) of the GLSL 1.30
spec:

"It is an error for a shader to statically write both
gl_ClipVertex and gl_ClipDistance."

Fixes piglit test mixing-clip-distance-and-clip-vertex-disallowed.c.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
inker.cpp
37bb1c4de2eb2fa80d09b6e8dc8f39814d790e09 12-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Check that gl_ClipDistance[] is not sized too large.

Fixes piglit tests
clip-distance-explicit-too-large-with-access.{frag,vert} and
clip-distance-explicit-too-large.{frag,vert}.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
93b9758d01e2542ec3c2b8672cca0ae19b257aac 06-Sep-2011 Paul Berry <stereotype441@gmail.com> glsl: Rework oversize array check for gl_TexCoord.

The check now applies both when explicitly declaring the size of
gl_TexCoord and when implicitly setting the size of gl_TexCoord by
accessing it using integral constant expressions.

This is prep work for adding similar size checks to gl_ClipDistance.

Fixes piglit tests texcoord/implicit-access-max.{frag,vert}.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
36c4b1a3da44a80624eab9da6543540b4b253f1d 12-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Add constant gl_MaxClipDistances.

Fixes piglit tests {vs,fs}-clip-distance-sizeable-to-max.shader_test.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_variable.cpp
af243b55ac346f39acda1ad20d90e7c8cc1a33c7 12-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Make gl_ClipDistance[] implicitly sized.

From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):

The gl_ClipDistance array is predeclared as unsized and must be
sized by the shader either redeclaring it with a size or indexing it
only with integral constant expressions.

Fixes piglit tests clip-distance-implicit-length.vert,
clip-distance-implicit-nonconst-access.vert, and
{vs,fs}-clip-distance-explicitly-sized.shader_test.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_variable.cpp
c0470bf77a038fd45441d1e55e6c89100996ff4b 07-Sep-2011 Brian Paul <brianp@vmware.com> glsl: s/int/unsigned/ to silence warning
r_reader.cpp
8ceb235c9cbb9504e32479db54287ed9387df75a 05-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/ir_reader: Make sure constants have the right number of components.

The list of numbers in (constant type (<numbers>)) needs to contain
exactly type->components() numbers (16 for a mat4, 3 for a vec3, etc.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
r_reader.cpp
6afce988a9ee41af4ac1244d488ae6b89edf8d13 05-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Fix invalid float constant in noise4 built-in.

Throwing away the extra numbers ought to match the existing behavior.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/ir/noise4
f6481be2988a872b16c76cc7f66acc6a2182bbd8 05-Sep-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Fix invalid vecN constants in hyperbolic functions.

Each of these vecN constants only provided one component, which is
illegal. The printed IR is meant to contain exactly as many components
as are necessary; the IR reader does not splat single values.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/ir/acosh
uiltins/ir/asinh
uiltins/ir/atanh
uiltins/ir/cosh
uiltins/ir/sinh
478034f34a59969103237eb78bc82f9e70fe81c2 28-Aug-2011 Bryan Cain <bryancain3@gmail.com> glsl: Use a separate div_to_mul_rcp lowering flag for integers.

Using multiply and reciprocal for integer division involves potentially
lossy floating point conversions. This is okay for older GPUs that
represent integers as floating point, but undesirable for GPUs with
native integer division instructions.

TGSI, for example, has UDIV/IDIV instructions for integer division,
so it makes sense to handle this directly. Likewise for i965.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Bryan Cain <bryancain3@gmail.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
r_optimization.h
ower_instructions.cpp
778ecc928388b2905d516743d0bdf19ffce03acb 25-Aug-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add GL_ARB_conservative_depth #define.

Forgotten in the patch that enabled the extension.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/glcpp-parse.y
8ce716257a3529d0aa750d7a7b344984c5ac4274 25-Aug-2011 Dave Airlie <airlied@redhat.com> glsl: fix crash when a const is passed to texelFetchOffset

while debugging texelFetchOffset we kept hitting the assert.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_function.cpp
c25b4943322ddd31d70d87464fe32be26ac6c858 25-Aug-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Bail after reporting an error for non-constant const_in parameters.

Otherwise we continue and hit the "Illegal formal parameter mode"
assertion.

Fixes negative compile test texelFetchOffset.frag in piglit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
st_function.cpp
b9eb4d8a59699e233255113acafae220c3d8fe3c 09-Aug-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Implement the GL_ARB_conservative_depth extension.

It's the same as GL_AMD_conservative_depth. The specs have slight
differences in wording, but don't differ in content or behavior.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser.yy
lsl_parser_extras.cpp
lsl_parser_extras.h
r.h
inker.cpp
707d614d100ae7fc72572b686e304dac47e11c87 24-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Make sure that Extensions.dummy_true is set to true

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
tandalone_scaffolding.cpp
2054652796d78996b1f9308ab1a75361d71e864e 26-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Uncomment textureSize prototypes.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
uiltins/profiles/130.frag
uiltins/profiles/130.vert
583b295bbf5777ce5ec0d57ce46269ceea4285c1 26-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Add support for textureSize (txs).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltins/tools/texture_builtins.py
1e3bcbdf31f09666ba358f35ff9486faee3642ca 25-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Add a new ir_txs (textureSize) opcode to ir_texture.

One unique aspect of TXS is that it doesn't have a coordinate.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
r.cpp
r.h
r_clone.cpp
r_hv_accept.cpp
r_print_visitor.cpp
r_reader.cpp
r_rvalue_visitor.cpp
pt_tree_grafting.cpp
6c8ea1eed66e9da82fb2b49b1e7f6d7f6064dbc4 18-Aug-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Make ir_validate actually visit ir_if nodes.

There is no ir_hierarchical_visitor::visit(ir_if *) method, since ir_if
is not a leaf node. Instead, there are visit_enter and visit_leave
methods. Use visit_enter arbitrarily (either would work fine, though
visit_enter will catch errors sooner).

Found thanks to a warning emitted by Clang.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
r_validate.cpp
b81b82df955ad19eec55fa593b533673f083f593 17-Aug-2011 Chia-I Wu <olvaffe@gmail.com> android: build glsl

This builds the static library libmesa_glsl and executable glsl_compiler
from glsl. glsl_compiler is only installed for engineering build.

Reviewed-by: Chad Versace <chad@chad-versace.us>
ndroid.gen.mk
ndroid.mk
b34770d83465f969eae57436d5aa9f4d31278c10 04-Aug-2011 Chia-I Wu <olvaffe@gmail.com> ralloc: include limits.h for SIZE_MAX on Android

Android does not define SIZE_MAX in stdint.h. We have to include
limits.h for it.

Reviewed-by: Chad Versace <chad@chad-versace.us>
alloc.c
31753b50f3927ab45f8442cbe687bab9cee6d3bc 01-Aug-2011 Chia-I Wu <olvaffe@gmail.com> glsl: remove an unnecessary header include

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad@chad-versace.us>
ain.cpp
64f11db5587dcfb04446dc9521a70ee8ce692b66 18-Aug-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused variable.
ower_if_to_cond_assign.cpp
af501e2b29c7fb161671dc5b3395eee1d1b16d3f 12-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Fix type error when lowering integer divisions

This patch fixes a bug when lowering an integer division:

x/y

to a multiplication by a reciprocal:

int(float(x)*reciprocal(float(y)))

If x was a plain int and y was an ivecN, the lowering pass
incorrectly assigned the type of the product to be float, when in fact
it should be vecN. This caused mesa to abort with an IR validation
error.

Fixes piglit tests {fs,vs}-op-div-int-ivec{2,3,4}.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_instructions.cpp
a313c29c777de0bc74c252f1d35eef7d3d907e1f 06-Aug-2011 Eric Anholt <eric@anholt.net> glsl: When assigning to a whole array, mark the array as accessed.

The vs-varying-array-mat2-col-row-wr test writes a mat2[3] constant to
a mat2[3] varying out array, and also statically accesses element 1 of
it on the VS and FS sides. At link time it would get trimmed down to
just 2 elements, and then codegen of the VS would end up generating
assignments to the unallocated last entry of the array. On the new
i965 VS backend, that happened to land on the vertex position.

Some issues remain in this test on softpipe, i965/old-vs and
i965/new-vs on visual inspection, but i965 is passing because only one
green pixel is probed, not the whole split green/red quad.
st_to_hir.cpp
303e05cc249df3baeb3ed7654b0de00e7b9358fc 03-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Add validations for ir_call.

This patch extends ir_validate.cpp to check the following
characteristics of each ir_call:

- The number of actual parameters must match the number of formal
parameters in the signature.

- The type of each actual parameter must match the type of the
corresponding formal parameter in the signature.

- Each "out" or "inout" actual parameter must be an lvalue.

Reviewed-by: Chad Versace <chad@chad-versace.us>
r_validate.cpp
a52b53b56e2b5d5853345d8bcd2a4ff50e495c20 03-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Make is_lvalue() and variable_referenced() const.

These functions don't modify the target instruction, so it makes sense
to make them const. This allows these functions to be called from ir
validation code (which uses const to ensure that it doesn't
accidentally modify the IR being validated).

Reviewed-by: Chad Versace <chad@chad-versace.us>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.cpp
r.h
67b5a3267d639c31d3ac4073be877ffb0f5637d3 02-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Perform implicit type conversions on function call out parameters.

When an out parameter undergoes an implicit type conversion, we need
to store it in a temporary, and then after the call completes, convert
the resulting value. In other words, we convert code like the
following:

void f(out int x);
float value;
f(value);

Into IR that's equivalent to this:

void f(out int x);
float value;
int out_parameter_conversion;
f(out_parameter_conversion);
value = float(out_parameter_conversion);

This transformation needs to happen during ast-to-IR convertion (as
opposed to, say, a lowering pass), because it is invalid IR for formal
and actual parameters to have types that don't match.

Fixes piglit tests
spec/glsl-1.20/compiler/qualifiers/out-conversion-int-to-float.vert and
spec/glsl-1.20/execution/qualifiers/vs-out-conversion-*.shader_test,
and bug 39651.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39651

Reviewed-by: Chad Versace <chad@chad-versace.us>
st_function.cpp
a352e2d08e0a141298275e77f25541218a97afb7 01-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Modify strategy for accumulating conditions when lowering if-statements

Previously if-statements were lowered from inner-most to outer-most
(i.e., bottom-up). All assignments within an if-statement would have
the condition of the if-statement appended to its existing condition.
As a result the assignments from a deeply nested if-statement would
have a very long and complex condition.

Several shaders in the OpenGL ES2 conformance test suite contain
non-constant array indexing that has been lowered by the shader
writer. These tests usually look something like:

if (i == 0) {
value = array[0];
} else if (i == 1) {
value = array[1];
} else ...

The IR for the last assignment ends up as:

(assign (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition) ) (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition@20) ) (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition@22) ) (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition@24) ) (var_ref if_to_cond_assign_condition@26) ) ) ) ) (x) (var_ref value) (array_ref (var_ref array) (constant int (5)))

The Mesa IR that is generated from this is just as awesome as you
might expect.

Three changes are made to the way if-statements are lowered.

1. Two condition variables, if_to_cond_assign_then and
if_to_cond_assign_else, are created for each if-then-else structure.
The former contains the "positive" condition, and the later contains
the "negative" condtion. This change was implemented in the previous
patch.

2. Each condition variable is added to a hash-table when it is created.

3. When lowering an if-statement, assignments to existing condtion
variables get the current condition anded. This ensures that nested
condition variables are only set to true when the condition variable
for all outer if-statements is also true.

Changes #1 and #3 combine to ensure the correctness of the resulting
code.

4. When a condition assignment is encountered with a condition that is
a dereference of a previously added condition variable, the condition
is not modified.

Change #4 prevents the continuous accumulation of conditions on
assignments.

If the original if-statements were:

if (x) {
if (a && b && c && d && e) {
...
} else {
...
}
} else {
if (g && h && i && j && k) {
...
} else {
...
}
}

The lowered code will be

if_to_cond_assign_then@1 = x;
if_to_cond_assign_then@2 = a && b && c && d && e
&& if_to_cond_assign_then@1;
...
if_to_cond_assign_else@2 = !if_to_cond_assign_then
&& if_to_cond_assign_then@1;
...

if_to_cond_assign_else@1 = !if_to_cond_assign_then@1;
if_to_cond_assign_then@3 = g && h && i && j;
&& if_to_cond_assign_else@1;
...
if_to_cond_assign_else@3 = !if_to_cond_assign_then
&& if_to_cond_assign_else@1;
...

Depending on how instructions are emitted, there may be an extra
instruction due to the duplication of the '&&
if_to_cond_assign_{then,else}@1' on the nested else conditions. In
addition, this may cause some unnecessary register pressure since in
the simple case (where the nested conditions are not complex) the
nested then-condition variables are live longer than strictly
necessary.

Before this change, one of the shaders in the OpenGL ES2 conformance
test suite's acos_float_frag_xvary generated 348 Mesa IR instructions.
After this change it only generates 124. Many, but not all, of these
instructions would have also been eliminated by CSE.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_if_to_cond_assign.cpp
4a026d6ba50034c326eb6cfd0b555f57d83ab609 01-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Slight change to the code generated by if-flattening

Now the condition (for the then-clause) and the inverse condition (for
the else-clause) get written to separate temporary variables. In the
presence of complex conditions, this shouldn't result in more code
being generated. If the original if-statement was

if (a && b && c && d && e) {
...
} else {
...
}

The lowered code will be

if_to_cond_assign_then = a && b && c && d && e;
...
if_to_cond_assign_else = !if_to_cond_assign_then;
...

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_if_to_cond_assign.cpp
13df36ecb6c24ea36534fa0dfea917aca8233710 01-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Replace foreach_iter with foreach_list_safe

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_if_to_cond_assign.cpp
5c843785417225ba582878a15a5ae13b7b961aaa 01-Aug-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Make move_block_to_cond_assign not care which branch it's processing

This will make some future changes a bit easier to digest.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_if_to_cond_assign.cpp
c148ef6ddb3dbf256c26d82ed2f45f1fde55a231 04-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: validate IR after linking (debug builds only)

At least one of the invariants verified by IR validation concerns the
relative ordering of toplevel constructs in the IR: references to
global variables must come after the declarations of those global
variables.

Since linking affects the ordering of toplevel constructs in the IR,
it's possible that a bug in the linker will cause invalid IR to be
generated, even if all the pre-linked shaders are valid. (In fact,
such a bug was fixed by the previous commit.)

Bugs like this are easily masked by further optimization passes,
particularly inlining. So to make them easier to track down, this
patch addes an IR validation step right after linking, and before
final optimization occurs. The validation only occurs on debug
builds.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
01a851c296347d8e9d2166b3c83eab97404c0670 04-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: When linking, emit functions at the tail of the final linked program.

When link_functions.cpp adds a new function to the final linked
program, it needs to add it after any global variable declarations
that the function refers to, otherwise the IR will be invalid (because
variable declarations must occur before variable accesses). The
easiest way to do that is to have the linker emit functions to the
tail of the final linked program.

The linker used to emit functions to the head of the final linked
program, in an effort to keep callees sorted before their callers.
However, this was not reliable: it didn't work for functions declared
or defined in the same compilation unit as main, for diamond-shaped
patterns in the call graph, or for some obscure cases involving
overloaded functions. And no code currently relies on this sort
order.

No Piglit regressions with i965 Ironlake.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ink_functions.cpp
d4144a123b603d3c33cb356cf3c8e5ae4653594e 02-Aug-2011 Paul Berry <stereotype441@gmail.com> glsl: Check array size is const before asserting that no IR was generated.

process_array_type() contains an assertion to verify that no IR
instructions are generated while processing the expression that
specifies the size of the array. This assertion needs to happen
_after_ checking whether the expression is constant. Otherwise we may
crash on an illegal shader rather than reporting an error.

Fixes piglit tests array-size-non-builtin-function.vert and
array-size-with-side-effect.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
789ee6516bfca289e1948ff8f2c147b94286a0e0 30-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Constant-fold built-in functions before outputting IR

Rearranged the logic for converting the ast for a function call to
hir, so that we constant fold before emitting any IR. Previously we
would emit some IR, and then only later detect whether we could
constant fold. The unnecessary IR would usually get cleaned up by a
later optimization step, however in the case of a builtin function
being used to compute an array size, it was causing an assertion.

Fixes Piglit test array-size-constant-relational.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38625
st_function.cpp
0d81b0e18494a80c4326fbc98837842959675869 30-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Emit function signatures at toplevel, even for built-ins.

The ast-to-hir conversion needs to emit function signatures in two
circumstances: when a function declaration (or definition) is
encountered, and when a built-in function is encountered.

To avoid emitting a function signature in an illegal place (such as
inside a function), emit_function() checked whether we were inside a
function definition, and if so, emitted the signature before the
function definition.

However, this didn't cover the case of emitting function signatures
for built-in functions when those built-in functions are called from
inside the constant integer expression that specifies the length of a
global array. This failed because when processing an array length, we
are emitting IR into a dummy exec_list (see process_array_type() in
ast_to_hir.cpp). process_array_type() later checks (via an assertion)
that no instructions were emitted to the dummy exec_list, based on the
reasonable assumption that we shouldn't need to emit instructions to
calculate the value of a constant.

This patch changes emit_function() so that it emits function
signatures at toplevel in all cases.

This partially fixes bug 38625
(https://bugs.freedesktop.org/show_bug.cgi?id=38625). The remainder
of the fix is in the patch that follows.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st.h
st_function.cpp
st_to_hir.cpp
lsl_parser_extras.h
482338842db6ad387316b52fbe9602eee56ad082 01-Aug-2011 Paul Berry <stereotype441@gmail.com> Revert "glsl: Skip processing the first function's body in do_dead_functions()."

opt_dead_functions contained a shortcut to skip processing the first
function's body, based on the assumption that IR functions are
topologically sorted, with callees always coming before their callers
(therefore the first function cannot contain any calls).

This assumption turns out not to be true in general. For example, the
following code snippet gets translated to IR that violates this
assumption:

void f();
void g();
void f() { g(); }
void g() { ... }

In practice, the shortcut didn't cause bugs because of a coincidence
of the circumstances in which opt_dead_functions is called:

(a) we do inlining right before dead function elimination, and
inlining (when successful) eliminates all calls.

(b) for user-defined functions, inlining is always successful, because
previous optimization passes (during compilation) have reduced
them to a form that is eligible for inlining.

(c) the function that appears first in the IR can't possibly call a
built-in function, because built-in functions are always emitted
before the function that calls them.

It seems unnecessarily fragile to have opt_dead_functions depend on
these coincidences. And the next patch in this series will break (c).
So I'm reverting the shortcut. The consequence will be a slight
increase in link time for complex shaders.

This reverts commit c75427f4c8767e131e5fb3de44fbc9d904cb992d.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_dead_functions.cpp
75a98740215d82447e5189b36d1dbfa59fcdd5db 08-Aug-2011 Brian Paul <brianp@vmware.com> glsl: silence warning about trailing comma in enum list
r_function.cpp
547212d963c70161915c46d64e8020617199fb8d 03-Aug-2011 Chia-I Wu <olv@lunarg.com> glsl: empty declarations should be valid

Unlike C++, empty declarations such as

float;

should be valid. The spec is not explicit about this actually.

Some apps that generate their shader sources may rely on this. This was
noted when porting one of them to Linux from Windows.

Reviewed-by: Chad Versace <chad@chad-versace.us>

Note: this is a candidate for the 7.11 branch.
st_to_hir.cpp
lsl_parser.yy
89193933cbd322cd08fb54232411a8a9221fcca8 29-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> mesa: Ensure that gl_shader_program::InfoLog is never NULL

This prevents assertion failures in ralloc_strcat. The ralloc_free in
_mesa_free_shader_program_data can be omitted because freeing the
gl_shader_program in _mesa_delete_shader_program will take care of
this automatically.

A bunch of this code could use a refactor to use ralloc a bit more
effectively. A bunch of the things that are allocated with malloc and
owned by the gl_shader_program should be allocated with ralloc (using
the gl_shader_program as the context).

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
ain.cpp
379a32f42ebca9feeb024633f7774661619fd62e 28-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Make linker_{error,warning} generally available

linker_warning is a new function. It's identical to linker_error
except that it doesn't set LinkStatus=false and it prepends "warning: "
on messages instead of "error: ".

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_function_detect_recursion.cpp
inker.cpp
inker.h
rogram.h
586e741ac1fa222d041990b265e820f5aa11344d 28-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Make linker_error set LinkStatus to false

Remove the other places that set LinkStatus to false since they all
immediately follow a call to linker_error. The function linker_error
was previously known as linker_error_printf. The name was changed
because it may seem surprising that a printf function will set an
error flag.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_function_detect_recursion.cpp
ink_functions.cpp
inker.cpp
inker.h
b1b4ea0b3679db0b8fddaa9663a10d4712bba3b7 28-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: improve the accuracy of the atan(x,y) builtin function.

The previous formula for atan(x,y) returned a value of +/- pi whenever
|x|<0.0001, and used a formula based on atan(y/x) otherwise. This
broke in cases where both x and y were small (e.g. atan(1e-5, 1e-5)).

This patch modifies the formula so that it returns a value of +/- pi
whenever |x|<1e-8*|y|, and uses the formula based on atan(y/x)
otherwise.
uiltins/ir/atan
d4c80f5f85c749df3fc091ff07b60ef4989fa6d9 27-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: improve the accuracy of the asin() builtin function.

The previous formula for asin(x) was algebraically equivalent to:

sign(x)*(pi/2 - sqrt(1-|x|)*(A + B|x| + C|x|^2))

where A, B, and C were arbitrary constants determined by a curve fit.

This formula had a worst case absolute error of 0.00448, an unbounded
worst case relative error, and a discontinuity near x=0.

Changed the formula to:

sign(x)*(pi/2 - sqrt(1-|x|)*(pi/2 + (pi/4-1)|x| + A|x|^2 + B|x|^3))

where A and B are arbitrary constants determined by a curve fit. This
has a worst case absolute error of 0.00039, a worst case relative
error of 0.000405, and no discontinuities.

I don't expect a significant performance degradation, since the extra
multiply-accumulate should be fast compared to the sqrt() computation.

Fixes piglit tests {vs,fs}-asin-float and {vs,fs}-atan-*
uiltins/ir/asin
5541920e0ac4ea8383c7f896daba24a304aafec6 01-Aug-2011 Chad Versace <chad@chad-versace.us> glsl: Remove duplicate comment

Remove duplicate doxgen comment for
ir_function.cpp:parameter_lists_match().

Signed-off-by: Chad Versace <chad@chad-versace.us>
r_function.cpp
5081d31a0ed753e7e23c5ed51f572d38aef66bfe 27-Jul-2011 Chad Versace <chad@chad-versace.us> glsl: Clarify ir_function::matching_sigature()

The function used a variable named 'score', which was an outright lie.
A signature matches or it doesn't; there is no fuzzy scoring.

Change the return type of parameter_lists_match() to an enum, and
let ir_function::matching_sigature() switch on that enum.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
r_function.cpp
a5ab9398e34287ed8cbb010d0758790e6692530c 27-Jul-2011 Chad Versace <chad@chad-versace.us> glsl: Fix conversions in array constructors

Array constructors obey narrower conversion rules than other constructors
[1] --- they use the implicit conversion rules [2] instead of the scalar
constructor conversions [3]. But process_array_constructor() was
incorrectly applying the broader rules.

[1] GLSL 1.50 spec, Section 5.4.4 Array Constructors, page 52 (58 of pdf)
[2] GLSL 1.50 spec, Section 4.1.10 Implicit Conversions, page 25 (31 of pdf)
[3] GLSL 1.50 spec, Section 5.4.1 Conversion, page 48 (54 of pdf)

To fix this, first check (with glsl_type::can_be_implicitly_converted_to)
if an implicit conversion is legal before performing the conversion.

Fixes:
piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bool-float.vert
piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bvec*-vec*.vert

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
st_function.cpp
6efe1a849586e46028c1eb763175904166ec7076 27-Jul-2011 Chad Versace <chad@chad-versace.us> glsl: Remove ir_function.cpp:type_compare()

The function is no longer used and has been replaced by
glsl_type::can_implicitly_convert_to().

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
r_function.cpp
8b3627fd7b52723102f070957d87f98073e92d7c 27-Jul-2011 Chad Versace <chad@chad-versace.us> glsl: Fix implicit conversions in non-constructor function calls

Context
-------
In ast_function_expression::hir(), parameter_lists_match() checks if the
function call's actual parameter list matches the signature's parameter
list, where the match may require implicit conversion of some arguments.
To check if an implicit conversion exists between individual arguments,
type_compare() is used.

Problems
--------
type_compare() allowed the following illegal implicit conversions:
bool -> float
bvecN -> vecN

int -> uint
ivecN -> uvecN

uint -> int
uvecN -> ivecN

Change
------
type_compare() is buggy, so replace it with glsl_type::can_be_implicitly_converted_to().
This comprises a rewrite of parameter_lists_match().

Fixes piglit:spec/glsl-1.20/compiler/built-in-functions/outerProduct-bvec*.vert

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
r_function.cpp
200e4972c1579e8dfaa6f11eee2a7e54baad4852 27-Jul-2011 Chad Versace <chad@chad-versace.us> glsl: Add method glsl_type::can_implicitly_convert_to()

This method checks if a source type is identical to or can be implicitly
converted to a target type according to the GLSL 1.20 spec, Section 4.1.10
Implicit Conversions.

The following commits use the method for a bugfix:
glsl: Fix implicit conversions in non-constructor function calls
glsl: Fix implicit conversions in array constructors

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
lsl_types.cpp
lsl_types.h
83f5d5e6aa58754f52c3579c27d810c497fe13a3 23-Jul-2011 Eric Anholt <eric@anholt.net> Add dependency generation for Mesa and GLSL dricore objects.

Reviewed-By: Christopher James Halse Rogers
<christopher.halse.rogers@canonical.com>
akefile
fe33c886a79f49378e5719909a51e794b7bb1c38 27-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: improve the accuracy of the radians() builtin function

The constant used in the radians() function didn't have enough
precision, causing a relative error of 1.676e-5, which is far worse
than the precision of 32-bit floats. This patch reduces the relative
error to 1.14e-9, which is the best we can do in 32 bits.

Fixes piglit tests {fs,vs}-radians-{float,vec2,vec3,vec4}.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/ir/radians
f622c6d7a23c480f6a17e4b3f81731231180e019 27-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add source location tracking to TODO list
ODO
5e1b7097f3d6fa60e563c8d629bbda1c34efb3c1 27-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Remove completed items from the TODO list
ODO
c1e591eed41b45c0fcf1dcac8b1b8aaeb6237a38 26-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Correctly return progress from lower_variable_index_to_cond_assign

lower_variable_index_to_cond_assign runs until it can't make any more
progress. It then returns the result of the last pass which will
always be false. This caused the lowering loop in
_mesa_ir_link_shader to end before doing one last round of
lower_if_to_cond_assign. This caused several if-statements (resulting
from lower_variable_index_to_cond_assign) to be left in the IR.

In addition to this change, lower_variable_index_to_cond_assign should
take a flag indicating whether or not it should even generate
if-statements. This is easily controlled by
switch_generator::linear_sequence_max_length. This would generate
much better code on architectures without any flow contol.

Fixes i915 piglit regressions glsl-texcoord-array and
glsl-fs-vec4-indexing-temp-src.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_variable_index_to_cond_assign.cpp
6c8f1f483a999005cae1da5b54cc8ca1904e7ce7 19-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Compare vector indices in blocks

Just like the non-constant array index lowering pass, compare all N
indices at once. For accesses to a vec4, this saves 3 comparison
instructions on a vector architecture.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_vec_index_to_cond_assign.cpp
90cc372400e1f5869baabd841823bbf9296d7b01 19-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Factor out code that generates block of index comparisons

Reviewed-by: Eric Anholt <eric@anholt.net>
r_optimization.h
ower_variable_index_to_cond_assign.cpp
156f85336f80d542569f0b0182bd27c7f3218e70 19-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Treat ir_dereference_array of non-var as a constant for lowering

Previously the code would just look at deref->array->type to see if it
was a constant. This isn't good enough because deref->array might be
another ir_dereference_array... of a constant. As a result,
deref->array->type wouldn't be a constant, but
deref->variable_referenced() would return NULL. The unchecked NULL
pointer would shortly lead to a segfault.

Instead just look at the return of deref->variable_referenced(). If
it's NULL, assume that either a constant or some other form of
anonymous temporary storage is being dereferenced.

This is a bit hinkey because most drivers treat constant arrays as
uniforms, but the lowering pass treats them as temporaries. This
keeps the behavior of the old code, so this change isn't making things
worse.

Fixes i965 piglit:

vs-temp-array-mat[234]-index-col-rd
vs-temp-array-mat[234]-index-col-row-rd
vs-uniform-array-mat[234]-index-col-rd
vs-uniform-array-mat[234]-index-col-row-rd

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_variable_index_to_cond_assign.cpp
601428d2bbcf650c746f7a10b47228948f0ea912 18-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: When lowering non-constant vector indexing, respect existing conditions

If the non-constant index was in the LHS of an assignment, any
existing condititon on that assignment would be lost.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_vec_index_to_cond_assign.cpp
5f83dfe5b70337bcffe215f7c32d0b862b5e7a3b 18-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: When lowering non-constant array indexing, respect existing conditions

If the non-constant index was in the LHS of an assignment, any
existing condititon on that assignment would be lost.

Fixes i965 piglit:

fs-temp-array-mat[234]-col-row-wr
fs-temp-array-mat[234]-index-col-row-wr
fs-temp-array-mat[234]-index-col-wr
fs-temp-array-mat[234]-index-row-wr
vs-varying-array-mat[234]-index-col-wr

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_variable_index_to_cond_assign.cpp
1731ac308631138ca98d34e8b7070c6e3f981939 18-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Rework lowering of non-constant array indexing

The previous implementation could easily get tricked if the LHS of an
assignment included a non-constant index that was "inside" another
dereference. For example:

mat4 m[2];
m[0][i] = vec4(0.0);

Due to the way it tracked whether the array was being assigned, it
would think that the non-constant index was in an r-value. The new
code fixes that by tracking l-values and r-values differently. The
index is also replaced by cloning the IR and replacing the index
variable instead of the odd way it was done before.

v2: Apply some simplifications suggested by Eric Anholt. Making
assignment_generator::rvalue be ir_dereference instead of ir_rvalue
simplified the code a bit.

Fixes i965 piglit fs-temp-array-mat[234]-index-wr and
vs-varying-array-mat[234]-index-wr.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34691
Reviewed-by: Eric Anholt <eric@anholt.net>
ower_variable_index_to_cond_assign.cpp
d2296e784aa8fad81c4910dcbbf61e826ce9a06a 18-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Split out part of variable_index_to_cond_assign_visitor::needs_lowering

Other code will soon need to know if an array needs lowering based
exclusively on the storage mode.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_variable_index_to_cond_assign.cpp
8d5f3cef795428d7a95120416122a39c10cff11c 18-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Move is_array_or_matrix outside visitor class

There's no reason for it to be there, and another class that may not
have access to the visitor will need it soon.

Reviewed-by: Eric Anholt <eric@anholt.net>
ower_variable_index_to_cond_assign.cpp
edaadd94cbae45dc3c1c5481e346f729ea2bc73b 22-Jul-2011 Vinson Lee <vlee@vmware.com> glsl: Add standalone_scaffolding.cpp to SConscript.
Conscript
659cdedb532e675da5676d40ee39278aadd8f0a1 05-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Add unit tests for lower_jumps.cpp

These tests invoke do_lower_jumps() in isolation (using the glsl_test
executable) and verify that it transforms the IR in the expected way.

The unit tests may be run from the top level directory using "make
check".

For reference, I've also checked in the Python script
create_test_cases.py, which was used to generate these tests. It is
not necessary to run this script in order to run the tests.

Acked-by: Chad Versace <chad@chad-versace.us>
ests/compare_ir
ests/lower_jumps/.gitignore
ests/lower_jumps/create_test_cases.py
ests/lower_jumps/lower_breaks_1.opt_test
ests/lower_jumps/lower_breaks_1.opt_test.expected
ests/lower_jumps/lower_breaks_2.opt_test
ests/lower_jumps/lower_breaks_2.opt_test.expected
ests/lower_jumps/lower_breaks_3.opt_test
ests/lower_jumps/lower_breaks_3.opt_test.expected
ests/lower_jumps/lower_breaks_4.opt_test
ests/lower_jumps/lower_breaks_4.opt_test.expected
ests/lower_jumps/lower_breaks_5.opt_test
ests/lower_jumps/lower_breaks_5.opt_test.expected
ests/lower_jumps/lower_breaks_6.opt_test
ests/lower_jumps/lower_breaks_6.opt_test.expected
ests/lower_jumps/lower_guarded_conditional_break.opt_test
ests/lower_jumps/lower_guarded_conditional_break.opt_test.expected
ests/lower_jumps/lower_pulled_out_jump.opt_test
ests/lower_jumps/lower_pulled_out_jump.opt_test.expected
ests/lower_jumps/lower_returns_1.opt_test
ests/lower_jumps/lower_returns_1.opt_test.expected
ests/lower_jumps/lower_returns_2.opt_test
ests/lower_jumps/lower_returns_2.opt_test.expected
ests/lower_jumps/lower_returns_3.opt_test
ests/lower_jumps/lower_returns_3.opt_test.expected
ests/lower_jumps/lower_returns_4.opt_test
ests/lower_jumps/lower_returns_4.opt_test.expected
ests/lower_jumps/lower_returns_main_false.opt_test
ests/lower_jumps/lower_returns_main_false.opt_test.expected
ests/lower_jumps/lower_returns_main_true.opt_test
ests/lower_jumps/lower_returns_main_true.opt_test.expected
ests/lower_jumps/lower_returns_sub_false.opt_test
ests/lower_jumps/lower_returns_sub_false.opt_test.expected
ests/lower_jumps/lower_returns_sub_true.opt_test
ests/lower_jumps/lower_returns_sub_true.opt_test.expected
ests/lower_jumps/lower_unified_returns.opt_test
ests/lower_jumps/lower_unified_returns.opt_test.expected
ests/lower_jumps/remove_continue_at_end_of_loop.opt_test
ests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected
ests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test
ests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected
ests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test
ests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected
ests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test
ests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected
ests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test
ests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected
ests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test
ests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected
ests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test
ests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected
ests/optimization-test
ests/sexps.py
f1f76e157ed1ba554fc3a0172113997344049e07 29-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: Create a standalone executable for testing optimization passes.

This patch adds a new build artifact, glsl_test, which can be used for
testing optimization passes in isolation.

I'm hoping that we will be able to add other useful standalone tests
to this executable in the future. Accordingly, it is built in a
modular fashion: the main() function uses its first argument to
determine which test function to invoke, removes that argument from
argv[], and then calls that function to interpret the rest of the
command line arguments and perform the test. Currently the only test
function is "optpass", which tests optimization passes.
gitignore
akefile
est.cpp
est_optpass.cpp
est_optpass.h
f129f618fe8a5397774484f1b7afb42d4be809a0 07-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Move functions into standalone_scaffolding.cpp for later reuse.

This patch moves the following functions from main.cpp (the main cpp
file for the standalone executable that is used to create the built-in
functions) to standalone_scaffolding.cpp, so that they can be re-used
in other standalone executables:

- initialize_context()*
- _mesa_new_shader()
- _mesa_reference_shader()

*initialize_context contained some code that was specific to main.cpp,
so it was split into two functions: initialize_context() (which
remains in main.cpp), and initialize_context_from_defaults() (which is
in standalone_scaffolding.cpp).
akefile
ain.cpp
tandalone_scaffolding.cpp
tandalone_scaffolding.h
76bccaff0c54aed10ffbc7c7dc744f1708921409 21-Jul-2011 Vinson Lee <vlee@vmware.com> glsl: Add ir_function_detect_recursion.cpp to SConscript.
Conscript
02c5ae1b3fef75d5c0a715313a69e6b95ebd5b95 11-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Reject shaders that contain static recursion

The GLSL 1.20 and later specs say:

"Recursion is not allowed, not even statically. Static recursion is
present if the static function call graph of the program contains
cycles."

Recursion is detected and rejected both a compile-time and at
link-time. The complie-time check happens to detect some cases that
may be removed by various optimization passes. The spec doesn't seem
to allow this, but other vendors (e.g., NVIDIA) appear to only check
at link-time after all optimizations.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33885
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
st_to_hir.cpp
r.h
r_function_detect_recursion.cpp
inker.cpp
1ad3ba4ad954b86751bd5b6ad0a431920bff9958 08-Jul-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Make prototype_string publicly available

Also clarify the documentation for one of the parameters.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_function.cpp
r.h
3875526926123259521514de9c8d675e3797275a 15-Jul-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Avoid massive ralloc_strndup overhead in S-Expression parsing.

When parsing S-Expressions, we need to store nul-terminated strings for
Symbol nodes. Prior to this patch, we called ralloc_strndup each time
we constructed a new s_symbol. It turns out that this is obscenely
expensive.

Instead, copy the whole buffer before parsing and overwrite it to
contain \0 bytes at the appropriate locations. Since atoms are
separated by whitespace, (), or ;, we can safely overwrite the character
after a Symbol. While much of the buffer may be unused, copying the
whole buffer is simple and guaranteed to provide enough space.

Prior to this, running piglit-run.py -t glsl tests/quick.tests with GLSL
1.30 enabled took just over 10 minutes on my machine. Now it takes 5.

NOTE: This is a candidate for stable release branches (because it will
make running comparison tests so much less irritating.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
_expression.cpp
_expression.h
4470ff2ebf56b22421038bc7272ef22c085b839d 20-Jul-2011 Brian Paul <brianp@vmware.com> glsl: silence warning in linker.cpp
inker.cpp
f07221056e1822187546b76387714b3172f9b2c5 12-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Ensure that sampler declarations are always uniform or "in" parameters.

This brings us into compliance with page 17 (page 22 of the PDF) of
the GLSL 1.20 spec:

"[Sampler types] can only be declared as function parameters or
uniform variables (see Section 4.3.5 "Uniform"). ... [Samplers]
cannot be used as out or inout function parameters."

The spec isn't explicit about whether this rule applies to
structs/arrays containing shaders, but the intent seems to be to
ensure that it can always be determined at compile time which sampler
is being used in each texture lookup. So to avoid creating a
loophole, the rule needs to apply to structs/arrays containing shaders
as well.

Fixes piglit tests spec/glsl-1.10/compiler/samplers/*.frag, and fixes
bug 38987.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38987
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
ddc1c96390b685bb95f7431e862c3a64fcefa085 12-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Move type_contains_sampler() into glsl_type for later reuse.

The new location, as a member function of glsl_type, is more
consistent with queries like is_sampler(), is_boolean(), is_float(),
etc. Placing the function inside glsl_type also makes it available to
any code that uses glsl_types.
lsl_types.cpp
lsl_types.h
r.cpp
66f4ac988d5053c9782d1390541b04f4d9c50078 29-Jun-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Only over-ride built-ins when a prototype has been seen

The GLSL spec says:

"If a built-in function is redeclared in a shader (i.e., a
prototype is visible) before a call to it, then the linker will
only attempt to resolve that call within the set of shaders that
are linked with it."

This patch enforces this behavior. When a function call is processed
a flag is set in the ir_call to indicate whether the previously seen
prototype is the built-in or not. At link time a call will only bind
to an instance of a function that matches the "want built-in" setting
in the ir_call.

This has the odd side effect that first call to abs() in the shader
below will call the built-in and the second will not:

float foo(float x) { return abs(x); }
float abs(float x) { return -x; }
float bar(float x) { return abs(x); }

This seems insane, but it matches what the spec says.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31744
r.h
ink_functions.cpp
7304909d6537e00252347a10d0bae54ffd77ff91 09-Jul-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Reject ambiguous function calls (multiple inexact matches).

According to the GLSL 1.20 specification, "it is a semantic error if
there are multiple ways to apply [implicit] conversions [...] such that
the call can be made to match multiple signatures."

Fixes a regression caused by 60eb63a855cb89962f2d5bb91e238ff2d1ab8702,
which implemented the wrong policy of finding a "closest" match.
However, this is not a revert, since the original code failed to
continue looking for an exact match once it found two inexact matches.

It's OK to have multiple inexact matches if there's also an exact match.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38971
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
r_function.cpp
067c9d7bd776260298ceabda026425ed7e4eb161 02-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Lower break instructions when necessary at the end of a loop.

Normally lower_jumps.cpp doesn't need to lower a break instruction
that occurs at the end of a loop, because all back-ends can produce
proper GPU instructions for a break instruction in this "canonical"
location. However, if other break instructions within the loop are
already being lowered, then a break instruction at the end of the loop
needs to be lowered too, since after the optimization is complete a
new conditional break will be inserted at the end of the loop.

Without this patch, lower_jumps.cpp may require multiple passes in
order to lower all jumps. This results in sub-optimal output because
lower_jumps.cpp produces a brand new set of temporary variables each
time it is run, and the redundant temporary variables are not
guaranteed to be eliminated by later optimization passes.

Fixes unit test test_lower_breaks_6.
ower_jumps.cpp
e71b4ab8a64bf978b2036976a41e30996eebb0c8 02-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: In lower_jumps.cpp, lower both branches of a conditional.

Previously, lower_jumps.cpp would break out of its loop after lowering
a jump instruction in just the then- or else-branch of a conditional,
and it would fail to lower a jump instruction occurring in the other
branch.

Without this patch, lower_jumps.cpp may require multiple passes in
order to lower all jumps. This results in sub-optimal output because
lower_jumps.cpp produces a brand new set of temporary variables each
time it is run, and the redundant temporary variables are not
guaranteed to be eliminated by later optimization passes.

Fixes unit test test_lower_returns_4.
ower_jumps.cpp
382cee91a4bbbee45897239e6802ccaa5a5ad9c3 01-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Use foreach_list in lower_jumps.cpp

The visitor class in lower_jumps.cpp never removes or replaces the
instruction being visited, but it frequently alters or removes the
instructions that follow it. Therefore, to make sure the altered IR
is visited, it needs to iterate through exec_lists using foreach_list
rather than visit_exec_list().

Without this patch, lower_jumps.cpp may require multiple passes in
order to lower all jumps. This results in sub-optimal output because
lower_jumps.cpp produces a brand new set of temporary variables each
time it is run, and the redundant temporary variables are not
guaranteed to be eliminated by later optimization passes.

Also, certain invariants assumed by lower_jumps.cpp may fail to hold,
causing assertion failures.

Fixes unit tests test_lower_pulled_out_jump,
test_lower_unified_returns, test_lower_guarded_conditional_break,
test_lower_return_non_void_at_end_of_loop, and test_lower_returns_3.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_jumps.cpp
03145ba655ad9173a74b853843eccaae78ff392f 02-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: lower unconditional returns and continues in loops.

Previously, lower_jumps.cpp would only lower return and continue
statements that appeared inside conditionals. This patch makes it
lower unconditional returns and continue statements that occur inside
a loop.

Such unconditional flow control statements would be unlikely to be
explicitly coded by a reasonable user, however they might arise as a
result of other optimizations.

Without this patch, lower_jumps.cpp might not lower certain return and
continue statements, causing some backends to fail.

Fixes unit tests test_lower_return_void_at_end_of_loop and
test_remove_continue_at_end_of_loop.
ower_jumps.cpp
afc9a50fba39df520046019c6993d7b7559329ea 01-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Lower unconditional return statements.

Previously, lower_jumps.cpp only lowered return statements that
appeared inside of an if statement.

Without this patch, lower_jumps.cpp might not lower certain return
statements, causing some back-ends to fail (as in bug #36669).

Fixes unit test test_lower_returns_1.
ower_jumps.cpp
dbaa2e627effbe1361e1a69c23cf247cf86f2709 01-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Refactor logic for determining whether to lower return statements.

Previously, do_lower_jumps.cpp determined whether to lower return
statements in ir_lower_jumps_visitor::should_lower_jumps(). Moved
this logic to ir_lower_jumps_visitor::visit(ir_function_signature *),
so that it can be used in determining whether to lower a return
statement at the end of a function.
ower_jumps.cpp
e2c748aec5363981a05f21f26a0c4d37ccf6419d 29-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: Add explanatory comments to lower_jumps.cpp.

No functional change.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_jumps.cpp
f4830be938c8fa33086f73cab19a53ab3e14cb9c 30-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: Make ir_reader able to read plain (return) statements.

Previously ir_reader was only able to handle return of non-void.

This patch is necessary in order to allow optimization passes to be
tested in isolation.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_reader.cpp
5fb79fc69f56cf2d8d44e4c6c2d8b862bc631139 05-Jul-2011 Paul Berry <stereotype441@gmail.com> glsl: Remove unused function prototypes.

No functional change. Remove prototypes for do_mod_to_fract() and
do_sub_to_add_neg(), which haven't existed since November 2010.
r_optimization.h
7eb7d67d50fccb64248d1fc6f490895048d7d32e 08-Jul-2011 Brian Paul <brianp@vmware.com> glsl: use casts to silence warning
inker.cpp
d32d4f780f9dad122adb63086da266aec6e88850 28-Jun-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Assign locations for fragment shader output

Fixes an assertion failure in the piglib out-01.frag
ARB_explicit_attrib_location test. The locations set via the layout
qualifier in fragment shader were not being applied to the shader
outputs. As a result all of these variables still had a location of
-1 set.

This may need some more work for pre-3.0 contexts. The problem is
dealing with generic outputs that lack a layout qualifier. There is
no way for the application to specify a location
(glBindFragDataLocation is not supported) or query the location
assigned by the linker (glGetFragDataLocation is not supported).

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624
Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Vinson Lee <vlee@vmware.com>
inker.cpp
174cef7fee7d400fc89a3ce68b7791d2aa3eb90f 25-Jun-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Don't choke when printing an anonymous function parameter

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38584
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r_print_visitor.cpp
0eb97979584b73907327eebc547302e6b8d8976a 28-Jun-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Track initial mask in constant propagation live set

The set of values initially available (before any kills) must be
tracked with each constant in the set. Otherwise the wrong component
can be selected after earlier components have been killed.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37383
Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Matthias Bentrup <matthias.bentrup@googlemail.com>
pt_constant_propagation.cpp
b043409adfa6ffa6dc78331258de52f7fa6d59aa 06-Jul-2011 Eric Anholt <eric@anholt.net> glsl: Suppress warning from matching_signature change.

gcc isn't smart enough to see that we only look at matched_score after
we've initialized it (because match != NULL happens at the same time)
r_function.cpp
abbbd14dd440cfbbe8b42279cf95c30eec5b495d 06-Jul-2011 Eric Anholt <eric@anholt.net> glsl: Fix make clean for dricore.
akefile
578f6a9534ec6ea1ffc6638b98f0b5570a85a19d 15-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't use MOD_TO_FRACT lowering on GLSL 1.30's % operator.

MOD_TO_FRACT was designed to lower the GLSL 1.20 mod() function, which
operates on floating point values. However, we also use ir_binop_mod
for GLSL 1.30's % operator, which operates on integers.

For now, make MOD_TO_FRACT only apply to floating-point mod operations.
In the future, we may want to add a lowering pass for integer-based mod.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
ower_instructions.cpp
ed92b912120394f3b19958effaa819d29bc6d059 15-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix DIV_TO_MUL_RCP lowering for uint result types.

f2i results in an int/ivec; we need i2u to get a uint/uvec.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
ower_instructions.cpp
8eb975394478a5c1ebd2bd8a12b5eb61cef808a7 15-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Distinguish "type mismatch" error messages for modulus operator.

Previously, it would simply say "type error" in three different cases:
- The LHS is not an integer
- The RHS is not an integer
- The LHS and RHS have different base types (int vs. uint)

Now the error messages state the specific problem.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
st_to_hir.cpp
60eb63a855cb89962f2d5bb91e238ff2d1ab8702 15-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Find the "closest" signature when there are multiple matches.

Previously, ir_function::matching_signature had a fatal bug: if a
function had more than one non-exact match, it would simply return NULL.

This occured, for example, when looking for max(uvec3, uvec3):
- max(vec3, vec3) -> score 1 (found first)
- max(ivec3, ivec3) -> score 1 (found second...used to return NULL here)
- max(uvec3, uvec3) -> score 0 (exact match...the right answer)

This did not occur for max(ivec3, ivec3) since the second match found
was an exact match.

The new behavior is to return a match with the lowest score. If there
is an exact match, that will be returned. Otherwise, a match with the
least number of implicit conversions is chosen.

Fixes piglit tests max-uvec3.vert and glsl-inexact-overloads.shader_test.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_function.cpp
6b1ba7ccef18232e5586fcda2ff75ef5bd05b57b 15-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Use i2u and u2i to implement constructor conversions.

Inspired by a patch from Bryan Cain <bryancain3@gmail.com>.

Fixes piglit tests:
- ctor-int-uint.vert
- ctor-ivec4-uvec4.vert
- ctor-uint-int.vert
- ctor-uvec4-ivec4.vert

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
st_function.cpp
3283e362e313f8a45fd6ee812efb737c0becc38c 14-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Revert "fix conversions from uint to bool and from..."

Reverts commit f41e1db3273a31285360241c4342f0a403ee0b03
"fix conversions from uint to bool and from float/bool to uint"

f2i, b2i, and b2i should not accept uint types. Use i2u and u2i.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
r_validate.cpp
20ef96c7ff3f17fbf97e0452a37553249b2b005c 15-Jun-2011 Bryan Cain <bryancain3@gmail.com> glsl: Add ir_unop_i2u and ir_unop_u2i operations.

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 <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
r.cpp
r.h
r_constant_expression.cpp
r_validate.cpp
4f799e614264d2409fd32e3e3992405bb3fd924f 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Use the default values of ir_assignment() in lower_mat_op_to_vec.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_mat_op_to_vec.cpp
e617a53a74cd27a322fd2dd05ff1c66c6437fde3 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Allow ir_assignment() constructor to not specify condition.

We almost never want to specify a condition, and when we do we're
already thinking about it (because we're writing a lowering pass
generating the condition), so a default argument should make the code
more pleasant to read.

NOTE: This is a candidate for the 7.11 branch (we want to be able to
cherry-pick future code).
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
r.h
487dd96c2706aa352ed44637507dd7f38ac80306 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Avoid making a temporary for lower_mat_op_to_vec if not needed.

Our copy propagation tends to be bad at handling the later array
accesses of the matrix argument we moved to a temporary. Generally we
don't need to move it to a temporary, though, so this avoids needing
more copy propagation complexity.

Reduces instruction count of some Unigine Tropics and Sanctuary
fragment shaders that do operations on uniform matrix arrays by 5.9%
on gen6.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_mat_op_to_vec.cpp
8fad8637ef42ccd064a4f90b090d8096ab968e58 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Make lower_mat_op_to_vec track derefs, not variables.

We were constrained to using temporaries because we were assuming
variables all over. This simplifies things a bit.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_mat_op_to_vec.cpp
408377aed1dfae30605709fe1a134880a0386aa8 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Rename lower_mat_op_to_vec operands/results to be less hungarian.

This awkward typing was to avoid shadowing the function argument (the
matrix) with the temporary deref (the column) before the
get_column()/get_element()s were moved into the expression/assignment
constructors. They're about to become not-variables, so the current
names had to go. This change is almost mechanical (other than
column_expr), so it should make the next diff clearer.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_mat_op_to_vec.cpp
a47fd5c27de2b2d61776faa524f9b7ab1c915cde 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Move get_{column,element} to expression args.

I think this makes the code more obvious by moving the declarations to
their single usage (now that we aren't using them to get at the ->type
field for expression constructors).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_mat_op_to_vec.cpp
e75b5954db52723a8590cd321b1998a079e9c1d4 24-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Drop explicit types of lower_mat_op_to_vec expressions.

The constructor can figure it out for us these days.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_mat_op_to_vec.cpp
3097715d41da4b725b7ce9f9d5bbc0f684cbf0a6 25-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic.

Instead of using a chain of manually maintained if/else blocks to
handle "#extension" directives, we now consult a table that specifies,
for each extension, the circumstances under which it is available, and
what flags in _mesa_glsl_parse_state need to be set in order to
activate it.

This makes it easier to add new GLSL extensions in the future, and
fixes the following bugs:

- Previously, _mesa_glsl_process_extension would sometimes set the
"_enable" and "_warn" flags for an extension before checking whether
the extension was supported by the driver; as a result, specifying
"enable" behavior for an unsupported extension would sometimes cause
front-end support for that extension to be switched on in spite of
the fact that back-end support was not available, leading to strange
failures, such as those in
https://bugs.freedesktop.org/show_bug.cgi?id=38015.

- "#extension all: warn" and "#extension all: disable" had no effect.

Notes:

- All extensions are currently marked as unavailable in geometry
shaders. This should not have any adverse effects since geometry
shaders aren't supported yet. When we return to working on geometry
shader support, we'll need to update the table for those extensions
that are available in geometry shaders.

- Previous to this commit, if a shader mentioned
ARB_shader_texture_lod, extension ARB_texture_rectangle would be
automatically turned on in order to ensure that the types
sampler2DRect and sampler2DRectShadow would be defined. This was
unnecessary, because (a) ARB_shader_texture_lod works perfectly well
without those types provided that the builtin functions that
reference them are not called, and (b) ARB_texture_rectangle is
enabled by default in non-ES contexts anyway. I eliminated this
unnecessary behavior in order to make the behavior of all extensions
consistent.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.cpp
9c4445de6e69d021491361d884bf172c05189d61 24-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: Changed extension enable bits to bools.

These were previously 1-bit-wide bitfields. Changing them to bools
has a negligible performance impact, and allows them to be accessed by
offset as well as by direct structure access.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.h
b078aad8ab22d840456688480a8c27d4664297ce 28-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: permit explicit locations on fragment shader outputs, not inputs

From the OpenGL docs for GL_ARB_explicit_attrib_location:

This extension provides a method to pre-assign attribute locations to
named vertex shader inputs and color numbers to named fragment shader
outputs.

This was accidentally implemented for fragment shader inputs. This
patch fixes it to apply to fragment shader outputs.

Fixes piglit tests
spec/ARB_explicit_attrib_location/1.{10,20}/compiler/layout-{01,03,06,07,08,09,10}.frag

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624
st_to_hir.cpp
d2c6cef18aa37d197eb323a0795969d271d02819 02-Jun-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix depth unbalancing problem in if-statement flattening

Previously, if max_depth were 1, the following code would see the
first if-statement (correctly) not get flattened, but the second
if-statement would (incorrectly) get flattened:

void main()
{
if (a)
gl_Position = vec4(0);

if (b)
gl_Position = vec4(1);
}

This is because the visit_leave(ir_if*) method would not decrement the
depth before returning on the first if-statement.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
ower_if_to_cond_assign.cpp
935e7e41266186c454e08c80aff40c34084d83c6 16-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: Flagged extension EXT_texture3D as "supported" in the builtin compiler.

Previously, the builtins in OES_texture_3D.{frag,vert} were only
compiling properly as a consequence of bug 38015, which allows
unsupported extensions to be enabled. This fix eliminates the builtin
compiler's reliance on bug 38015, so that bug 38015 can be fixed.
ain.cpp
de77324d8f14951e4dc17f570e49451a0cd33121 09-Jun-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Reject shaders that use too many varyings

Previously it was up to the driver or later code generator to reject
these shaders. It turns out that nobody did this.

This will need changes to support geometry shaders.

NOTE: This is a candidate for the stable branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37743
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
inker.cpp
41750107496858a047afa8d81d20fe903f285a78 17-Jun-2011 José Fonseca <jfonseca@vmware.com> scons: make embedding orthogonal to the platform

To enable embedding in platforms other than linux.
Conscript
ef8f6a8c59e88fb7498f3a0f7440bcc4ec1e8a98 15-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Actually implement int/ivec variants of abs().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>

NOTE: This is a candidate for stable release branches (and don't forget
to re-run "make builtins" after cherry-picking.)
uiltins/ir/abs
7c7a8a38e530a63717a2f374ae0574d8abf11e17 14-Jun-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/generate_builtins.py: Remove regexp to kill pointer addresses.

Commit 56ef62d9885f805bbfb2243dc860ff425d5b4d3b
"glsl: Generate readable unique names at print time."
changed ir_print_visitor to not generate @0x1234567 suffixes except
where necessary. So there's no need to manually remove them.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
uiltins/tools/generate_builtins.py
20f087863d00fed9823791a447932e74d77cc546 08-Jun-2011 Eric Anholt <eric@anholt.net> glsl: Fix incorrect optimization of instructions before discard statements.

The function was named "find_unconditional_discard", but didn't
actually check that the discard statement found was unconditional.
Fixes piglit glsl-fs-discard-04.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
pt_discard_simplification.cpp
6491e9593d5cbc5644eb02593a2f562447efdcbb 03-Jun-2011 Paul Berry <stereotype441@gmail.com> glsl: fixed printing of structure constants.

ir_print_visitor::visit(ir_constant *) was failing to index properly
into ir->type->fields.structure, so the first field name was being
reprinted for every field in the structure.

Signed-off-by: Brian Paul <brianp@vmware.com>
r_print_visitor.cpp
26b566e19cbfa189a6a158718f21859c0b7ed090 03-Jun-2011 Paul Berry <stereotype441@gmail.com> AST dump: fixed printing of conditionals.

ast_expression::print() had an incorrect index into the subexpressions
array, so (a ? b : c) was being incorrectly rendered as (a ? b : b).

Signed-off-by: Brian Paul <brianp@vmware.com>
lsl_parser_extras.cpp
de1df26b5c11a45f2b1ff2ddc7b8ec764356aa94 18-May-2011 Brian Paul <brianp@vmware.com> mesa: check that flex/bison are installed

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=36651

NOTE: This is a candidate for the 7.10 branch.
akefile
5a3a242a8fc4b9f0cac0e40786dd0c4831517473 19-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add compiler support for ARB_shader_texture_lod.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Marek Olšák <maraeo@gmail.com>
uiltins/profiles/ARB_shader_texture_lod.frag
uiltins/profiles/ARB_shader_texture_lod.vert
uiltins/tools/texture_builtins.py
lcpp/glcpp-parse.y
lsl_parser_extras.cpp
lsl_parser_extras.h
0f0179b8c278854fdbef283c5abaf95ad33351c3 03-May-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Remove extra newline from error message
st_function.cpp
5ba2e7adf01aaa855e36a577a47de8f4ddace99c 02-May-2011 Marek Olšák <maraeo@gmail.com> mesa: implement AMD_shader_stencil_export

It's just an alias of the ARB variant with some GLSL compiler changes.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser_extras.cpp
lsl_parser_extras.h
r_variable.cpp
f18a086326b2bc832a3c181e6bbec6a62e1b3fcd 24-Apr-2011 Bryan Cain <bryancain3@gmail.com> glsl: Fix typos in comments.
inker.cpp
08ba9778dbf3326bdfc8ca8035b51412032748ea 15-Apr-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/ast_to_hir: Only use the local 'type' variable as a temporary.

Lots of code (deleted by this patch) tried to make type == result->type,
but not all cases did. Don't pretend; just use result->type.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
f41e1db3273a31285360241c4342f0a403ee0b03 18-Apr-2011 Bryan Cain <bryancain3@gmail.com> glsl: fix conversions from uint to bool and from float/bool to uint

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
r_validate.cpp
edf2e4f79d5b27cb909b37fabc35e68d14af0834 19-Apr-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: 80-column wrapping and whitespace fixes
st_function.cpp
3d5cfcfed16c5a79bdf67027afe4ea8058b899cb 11-Apr-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Emit a warning when the left-hand operand of a comma has no effect

The expression

x = y, 5, 3;

will generate

0:7(9): warning: left-hand operand of comma expression has no effect

The warning is only emitted for the left-hand operands, becuase the
right-most operand is the result of the expression. This could be
used in an assignment, etc.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st_to_hir.cpp
9dacbe222641443af000a82161922a5ade206340 15-Apr-2011 Carl Worth <cworth@cworth.org> glcpp: Fix attempts to expand recursive macros infinitely (bug #32835).

The 095-recursive-define test case was triggering infinite recursion
with the following test case:

#define A(a, b) B(a, b)
#define C A(0, C)
C

Here's what was happening:

1. "C" was pushed onto the active list to expand the C node

2. While expanding the "0" argument, the active list would be
emptied by the code at the end of _glcpp_parser_expand_token_list

3. When expanding the "C" argument, the active list was now empty,
so lather, rinse, repeat.

We fix this by adjusting the final popping at the end of
_glcpp_parser_expand_token_list to never pop more nodes then this
particular invocation had pushed itself. This is as simple as saving
the original state of the active list, and then interrupting the
popping when we reach this same state.

With this fix, all of the glcpp-test tests now pass.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=32835
Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-and-tested-by: Kenneth Graunke <kenneth@whitecape.org>
lcpp/glcpp-parse.y
3d78f83cde0286ef352fefa1b018563c11642ff1 15-Apr-2011 Carl Worth <cworth@cworth.org> Add expected file for 095-recursive-define test case.

It's clear enough that the current segmentation fault isn't what we
want. And it's also very easy to know what we do want here, (just
check with any functional C preprocessor such as "gcc -E").

Add the desired output as an expected file so that the test suite
gives useful output, (showing the omitted output and the segfault),
rather than just reporting "No such file" for the expected file.
lcpp/tests/095-recursive-define.c.expected
02d293c08ee2375fc43b343bfc9b074f33a9063c 15-Apr-2011 Carl Worth <cworth@cworth.org> glcpp: Simplify calling convention of parser's active_list functions

These were all written as generic list functions, (accepting and returning
a list to act upon). But they were only ever used with parser->active as
the list. By simply accepting the parser itself, these functions can update
parser->active and now return nothing at all. This makes the code a bit
more compact.

And hopefully the code is no less readable since the functions are also
now renamed to have "_parser_active" in the name for better correlation
with nearby tests of the parser->active field.
lcpp/glcpp-parse.y
0b80f2d4c9fd672d75d647104bf0b0fdafec9dda 14-Apr-2011 Carl Worth <cworth@cworth.org> glcpp: Add --valgrind option to the glcpp-test utility

The common case for this test suite is to quickly test that everything
returns the correct results. In this case, the second run of the test
suite under valgrind was just annoying, (and the user would often
interrupt it).

Now, do what is wanted in the common case by default (just run the
test suite), and require a run with "glcpp-test --valgrind" in order
to test with valgrind.
lcpp/tests/glcpp-test
6affa4806a74c0f81fefa0be0212ec8574a74f4d 14-Apr-2011 Carl Worth <cworth@cworth.org> Add an expected file for 084-unbalanced-parentheses

The expected file here captures the current behavior of glcpp (which
is to generate an obscure "syntax error, unexpected $end" diagnostic
for this case).

It would certainly be better for glcpp to generate a nicer diagnostic,
(such as "missing closing parenthesis in function-like macro
definition" or so), but the current behavior is at least correct, and
expected. So we can make the test suite more useful by marking the
current behavior as expected.
lcpp/tests/084-unbalanced-parentheses.c.expected
d3c6ed382d8e02cd9f9e2cc77208b800abe17d54 14-Apr-2011 Carl Worth <cworth@cworth.org> Add an expected file for 094-divide-by-zero-short-circuit

The expected file here captures the current behavior of glcpp (which
is to generate a division-by-zero error) for this case.

It's easy to argue that it should be short-circuiting the evaluation
and not generating the diagnostic (which happens to be what gcc does).
But it doesn't seem like we should force this behavior on our
pre-processor, (and, as always, the GLSL specification of the
pre-processor is too vague on this point).
lcpp/tests/094-divide-by-zero-short-circuit.c
lcpp/tests/094-divide-by-zero-short-circuit.c.expected
ea3b2560b1dd0585fcf82a5d3179826374ae03b2 14-Apr-2011 Carl Worth <cworth@cworth.org> Add an expected file for 093-divide-by-zero

This test is behaving just fine already---it's generating an informative
diagnostic, ("error: division by 0 in preprocessor directive"), so adding
this in the expected file makes things pass.
lcpp/tests/093-divide-by-zero.c.expected
756c262756b2434efeb2c2a33a180fda0757a6e5 10-Apr-2011 Eric Anholt <eric@anholt.net> glsl: Perform type checking on "^^" operands.

We were letting any old operand through, which generally resulted in
assertion failures later.

Fixes array-logical-xor.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
175829f1a8ab0df7594131cc569462e45c1974ec 09-Apr-2011 Eric Anholt <eric@anholt.net> glsl: When we've emitted a semantic error for ==, return a bool constant.

This prevents later errors (including an assertion failure) from
cascading the failure.

Fixes invalid-equality-04.vert.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33303
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@intel.com>
st_to_hir.cpp
9e04b190b5f59c5b375645f5756a6edd98a7f90c 09-Apr-2011 Eric Anholt <eric@anholt.net> glsl: Semantically check the RHS of `||' even when short-circuiting.

We just do the AST-to-HIR processing, and only push the instructions
if needed in the constant false case.

Fixes glslparsertest/glsl2/logic-02.frag

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
7ec0c9789669ac88fcdd66c562e6d58281b477ce 09-Apr-2011 Eric Anholt <eric@anholt.net> glsl: Semantically check the RHS of `&&' even when short-circuiting.

We just do the AST-to-HIR processing, and only push the instructions
if needed in the constant true case.

Fixes glslparsertest/glsl2/logic-01.frag

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
01822706ec2c2501a2cd2431a90c56b334b79a5c 10-Apr-2011 Eric Anholt <eric@anholt.net> glsl: Avoid cascading errors when looking for a scalar boolean and failing.

By always using a boolean, we should generally avoid further
complaints. The failure case I see is logic_not, where the user might
understandably make the mistake of using `!' on a boolean vector (like
a piglit case did recently!), and then get a further complaint that
the new boolean type doesn't match the bvec it gets assigned to.

Fixes invalid-logic-not-06.vert (assertion failure when the bad type
ends up in an expression and ir_constant_expression gets angry).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33314
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
6a35cbb656e0f8a2479a63eadefb1ab85f42d490 03-Apr-2011 Eric Anholt <eric@anholt.net> glsl/opt_cpe: Reenable opt_copy_propagation_elements.cpp pass.
lsl_parser_extras.cpp
909bd476ca65035b93399c7b95f7118b1cded3f2 08-Apr-2011 Eric Anholt <eric@anholt.net> glsl/opt_cpe: Fix a crash when a kill kills for two reasons.

Fixes glsl-copy-propagation-loop-2 when this optimization pass is
re-enabled.

Reported-by: David Lamparter <equinox@diac24.net>
pt_copy_propagation_elements.cpp
487debfda56ad3855db655688186401b0dd75233 03-Apr-2011 Eric Anholt <eric@anholt.net> glsl/opt_cpe: Kill when the assignment isn't something we recognize.

A few GLES2 tests tripped over this when using array dereferences to
hit channels on the LHS (see piglit test
glsl-copy-propagation-vector-indexing). We wouldn't find the
ir_dereference_variable, and assume that that meant that it wasn't an
assignment to a scalar/vector, and thus not notice that the variable
had been changed.
pt_copy_propagation_elements.cpp
03eade164d45cc35422dfc03aeaf579c9c3183f9 08-Apr-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Make GL_ARB_shader_stencil_export enable block be similar to other blocks

Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser_extras.cpp
f2bda1b5664cd8a8744798926f2562212229d938 08-Apr-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Only let a shader enable GL_ARB_draw_instanced if the driver supports it

Also make the GL_ARB_draw_instanced block follow the same pattern as
the other blocks.

Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
lsl_parser_extras.cpp
89d81ab16c05818b290ed735c1343d3abde449bf 25-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Calcluate Mesa state slots in front-end instead of back-end

This should be the last bit of infrastructure changes before
generating GLSL IR for assembly shaders.

This commit leaves some odd code formatting in ir_to_mesa and brw_fs.
This was done to minimize whitespace changes / reindentation in some
loops. The following commit will restore formatting sanity.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chad Versace <chad.versace@intel.com>
r.h
r_clone.cpp
r_variable.cpp
inker.cpp
92e412e788931ad464125113a64eec8a8223cda3 25-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Move _mesa_builtin_uniform_desc from uniforms.c to ir_variable.cpp

This array is going to be used in the main compiler soon. Leaving
them uniforms.c caused problems for building the stand-alone compiler.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chad Versace <chad.versace@intel.com>
r_variable.cpp
8752824f27c979986ae855667337e89637b005fb 27-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Accept precision qualifiers on sampler types, but only in ES.

GLSL 1.30 states clearly that only float and int are allowed, while the
GLSL ES specification's issues section states that sampler types may
take precision qualifiers.

Fixes compilation failures in 3DMarkMobileES 2.0 and GLBenchmark 2.0.

NOTE: This is a candidate for stable release branches.
st_to_hir.cpp
56ef62d9885f805bbfb2243dc860ff425d5b4d3b 25-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Generate readable unique names at print time.

Since GLSL IR allows multiple ir_variables to share the same name, we
need to generate unique names when printing the IR. Previously, we
always used %s@%p, appending the ir_variable's memory address.

While this worked, it had two drawbacks:
- When there aren't duplicates, the extra "@0x669a3e88" is useless
and makes the code harder to read.
- Real duplicates were hard to tell apart:
channel_expressions@0x6699e3c8 vs. channel_expressions@0x6699ddd8

We now append @2, @3, @4, and so on, but only where necessary to
distinguish duplicates. Since we only do this at print time, any
performance impact is irrelevant.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <idr@freedesktop.org>
r_print_visitor.cpp
r_print_visitor.h
dfdff940b6cb69b882595e16cdab12b9f440c201 25-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Make add_variable, add_uniform, et. al. have similar signatures

While making some other changes in this area I was finding it annoying
each of these functions took mostly the same set of parameters in
differing orders.
r_variable.cpp
0d9d036004f135c38990c60f46074b70cff6e663 25-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix off-by-one error setting max_array_access for non-constant indexing

NOTE: This is a candidate for the stable branches.
st_to_hir.cpp
bc83f6bd585bba6dee3fa2264d32ab59e9a9c99e 25-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add array access bounds checking to ir_validate
r_validate.cpp
28f1d6ab4913a9e37cacc7e903f8ce04bb3c8e1c 25-Mar-2011 José Fonseca <jfonseca@vmware.com> glsl: Add void to _mesa_destroy_shader_compiler() argument list.

At least MSVC sees a distinction between foo() and foo(void) and warns
about it.
lsl_parser_extras.h
f3a828c21fcb95c67868f0224ab4ec92f54eee7f 16-Mar-2011 Tobias Droste <tdroste@gmx.de> autoconf: don't use CFLAGS for cpp files

Signed-off-by: Tobias Droste <tdroste@gmx.de>
akefile
6b3713f8b864cbe238b0e7efb28bca54b91ef0f8 16-Mar-2011 José Fonseca <jfonseca@vmware.com> glsl2: Silence unused added variable gcc warning.
lsl_symbol_table.cpp
d350ef1682ad6432b8a10e0f6aabdfe77ccb4370 15-Mar-2011 Brian Paul <brianp@vmware.com> glsl: add cast to silence signed/unsigned comparison warning
r.cpp
85caea29c18fad89050ac366c558afef568dcb3f 16-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Only allow unsized array assignment in an initializer

It should have been a tip when the spec says "However, implicitly
sized arrays cannot be assigned to. Note, this is a rare case that
*initializers and assignments appear to have different semantics*."
(empahsis mine)

Fixes bugzilla #34367.

NOTE: This is a candidate for stable release branches.
st_to_hir.cpp
c75427f4c8767e131e5fb3de44fbc9d904cb992d 11-Mar-2011 Eric Anholt <eric@anholt.net> glsl: Skip processing the first function's body in do_dead_functions().

It can't call anything, so there's no point.
pt_dead_functions.cpp
11af045ea8080435de0be74d8765190287b64f8b 11-Mar-2011 Eric Anholt <eric@anholt.net> glsl: Whitespace fixup in opt_dead_functions.cpp.
pt_dead_functions.cpp
2b13e135942ea7ebe1426a1809bf0efb7891387d 11-Mar-2011 Eric Anholt <eric@anholt.net> glsl: Skip processing of expression trees in discard simplification.

It only cares about "if", "loop", and "discard".
pt_discard_simplification.cpp
05cf1ad82eb903eb07d7b379d0ea610bb43dd84a 11-Mar-2011 Eric Anholt <eric@anholt.net> glsl: Reduce processing of expression trees in do_structure_splitting.

Most of the time we don't have a non-uniform struct variable in the
shader, so this cuts the time spent in do_structure_splitting during
glean texCombine by about 2/3.
pt_structure_splitting.cpp
991fa4d3d07a3ebda2a1398d346b18b3afbaa736 11-Mar-2011 Eric Anholt <eric@anholt.net> glsl: Skip processing expression trees in do_if_simplification().

Reduces time spent in this during glean texCombine by about 2/3.
pt_if_simplification.cpp
d3a444af2d4c42a23e9ec78dbef4c3ee45e1e50c 11-Mar-2011 Eric Anholt <eric@anholt.net> glsl: Skip processing expression trees in optimize_redundant_jumps()

Cuts the time spent in this function during glean texCombine by 2/3.
pt_redundant_jumps.cpp
a946e840715b481065db2347696eea6bae0c9dd6 12-Mar-2011 Jose Fonseca <jfonseca@vmware.com> scons: copy hash_table.c, symbol_table.c to glsl directory

This fixes an issue where the .obj files wound up in the src/
directory rather than the build/ directory. That prevented
combined 32-bit and 64-bit builds from working.

Signed-off-by: Brian Paul <brianp@vmware.com>
Conscript
233b88eab9d8095523ebae3c4be1dbf2e2bd856a 25-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Explicitly specify a type when reading/printing ir_texture.

This is necessary for GLSL 1.30+ shadow sampling functions, which return
a single float rather than splatting the value to a vec4 based on
GL_DEPTH_TEXTURE_MODE.
uiltins/tools/texture_builtins.py
r.cpp
r.h
r_print_visitor.cpp
r_reader.cpp
cb3317b85a9b8916317cb733ef4e6f13eaf0d890 07-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Add support for 130-style Shadow sampler variants.
uiltins/tools/texture_builtins.py
dedc81e1dced8768334c300d630b4683fd8a1ba2 03-Mar-2011 Chad Versace <chad@chad-versace.us> glsl: Document glsl_type::sampler_dimensionality
lsl_types.h
29e013e58be93aa6ed760393cf77ef34ca1d57c0 24-Nov-2010 Eric Anholt <eric@anholt.net> mesa: Add gl_MESAFogParamsOptimized for our special pre-computed fog params.

It would be nice if we handled optimized uniform math like this in
some generic way, since people often end up doing uniform expressions
in shaders, but for now keep this hard-coded like it was in the
texenvprogram code.
uiltin_variables.h
20f7a6f11aef492d5ca13e8ba9525eb2961d483c 12-Nov-2010 Eric Anholt <eric@anholt.net> mesa: Add a builtin uniform for the ATI_envmap_bumpmap rotation matrix.

For fixed function fragment processing in GLSL IR, we want to be able
to reference this state value. gl_* not explicitly permitted is
reserved, so using this variable name internally shouldn't be any
issue.
uiltin_variables.h
0eab3a8a976ea282063710d5aa7d1709abc182c5 10-Mar-2011 Brian Paul <brianp@vmware.com> glsl: silence warning in printf() with a cast
r_validate.cpp
bdb6a6ef83af62f2eda692d91ee2476c3fd1ce3a 08-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Use insert_before for lists instead of open coding it
pt_function_inlining.cpp
60f898a90ebd29d2593866faa1f2d6f65961a414 08-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Add imported functions to the linked IR

Fixes piglit test glsl-function-chain16 and bugzilla #34203.

NOTE: This is a candidate for stable release branches.
ink_functions.cpp
8bbfbb14eee53e42a488ba24c0cfc9ffa1cf6318 08-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add several function / call related validations

The signature list in a function must contain only ir_function_signature nodes.

The target of an ir_call must be an ir_function_signature.

These were added while trying to debug Mesa bugzilla #34203.
r_validate.cpp
2df56b002dcc5d7e91515bd0ca741677f0172b38 08-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Function signatures cannot have NULL return type

The return type can be void, and this is the case where a `_ret_val'
variable should not be declared.
r_validate.cpp
pt_function_inlining.cpp
09a4ba0fc31fa8fc193dfb7b4fd78e32722b8312 05-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Process redeclarations before initializers

If an array redeclaration includes an initializer, the initializer
would previously be dropped on the floor. Instead, directly apply the
initializer to the correct ir_variable instance and append the
generated instructions.

Fixes bugzilla #34374 and piglit tests glsl-{vs,fs}-array-redeclaration.

NOTE: This is a candidate for stable release branches. 0292ffb8 and
8e6cb9fe are also necessary.
st_to_hir.cpp
0292ffb85c03e9fa15b9395e3875109dd8979292 05-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Refactor AST-to-HIR code handling variable initializers
st_to_hir.cpp
8e6cb9fe51a2237e51b47198eb7d46b14ad288b5 05-Mar-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Refactor AST-to-HIR code handling variable redeclarations
st_to_hir.cpp
c8e904e159e6ddfe68fa5dc4de72b12eb7b7747d 04-Mar-2011 José Fonseca <jfonseca@vmware.com> scons: Unbreak mingw cross compilation.
Conscript
53789834176396ae69e21e460881600f36124fb5 04-Mar-2011 José Fonseca <jfonseca@vmware.com> scons: Get glsl2 and glcpp programs building correctly.
Conscript
12d17bcadf79d473b29c902c1ac949dcc65ff354 04-Mar-2011 José Fonseca <jfonseca@vmware.com> glsl/glcpp: Use stdio.h instead of unistd.h.
lcpp/glcpp.c
f52660c3dc85632b4dce76d16bf6d78266c35173 04-Mar-2011 José Fonseca <jfonseca@vmware.com> glsl: Define YY_NO_UNISTD_H on MSVC.
lcpp/glcpp-lex.l
lsl_lexer.ll
09e1bebc25140eecafa0c3eacefcf63010ce4f10 03-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove trailing contexts from #if rules.

These are now unnecessary.
lcpp/glcpp-lex.l
f20656e9446b9acde55b9dd41a2b47d7d5b7a56a 01-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Rework lexer to use a SKIP state rather than REJECT.

Previously, the rule deleted by this commit was matched every single
time (being the longest match). If not skipping, it used REJECT to
continue on to the actual correct rule.

The flex manual advises against using REJECT where possible, as it is
one of the most expensive lexer features. So using it on every match
seems undesirable. Perhaps more importantly, it made it necessary for
the #if directive rules to contain a look-ahead pattern to make them
as long as the (now deleted) "skip the whole line" rule.

This patch introduces an exclusive start state, SKIP, to avoid REJECTs.
Each time the lexer is called, the code at the top of the rules section
will run, implicitly switching the state to the correct one.

Fixes piglit tests 16384-consecutive-chars.frag and
16385-consecutive-chars.frag.
lcpp/glcpp-lex.l
b56f30c2b23f6d7b5499f01fa2d3ee04f2ce546e 03-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp/tests: Update 063-comments.c.expected to match output.

The expected result has been out of sync with what glcpp produces for
some time; glcpp's actual result seems to be correct and is very close to
GCC's cpp. Updating this will make it easier to catch regressions in
upcoming commits.
lcpp/tests/063-comments.c.expected
5d0e8beaa2051c28a7ac941e8aaad286e39e1267 03-Mar-2011 José Fonseca <jfonseca@vmware.com> scons: More tweaks to fix MinGW build.
Conscript
dbfbb8cf6da472e9000481ebd6a2a6b4e4845560 03-Mar-2011 José Fonseca <jfonseca@vmware.com> scons: Ensure generated headers are in the include path.
Conscript
2e756f3d6f15d61297a3bb4efe6a88c29081a5eb 03-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused glcpp/Makefile.am.

This is a remnant of when glsl2 lived in its own repository.
lcpp/Makefile.am
8be828c3b31e8e6d554888ead53878bebb2a3370 03-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove 'tests' subfolder.

These have long since moved to piglit and aren't useful to have here.
ests/array-01.glsl
ests/array-02.glsl
ests/array-03.glsl
ests/array-04.glsl
ests/array-05.glsl
ests/array-06.glsl
ests/array-07.glsl
ests/array-08.glsl
ests/array-09.glsl
ests/array-10.glsl
ests/array-11.glsl
ests/array-12.glsl
ests/array-13.glsl
ests/attribute-01.glsl
ests/attribute-02.glsl
ests/attribute-03.glsl
ests/attribute-04.glsl
ests/attribute-05.glsl
ests/attribute-06.glsl
ests/attribute-07.glsl
ests/attribute-08.glsl
ests/attribute-09.glsl
ests/attribute-10.glsl
ests/attribute-11.glsl
ests/condition-01.glsl
ests/condition-02.glsl
ests/condition-03.glsl
ests/condition-04.glsl
ests/condition-05.glsl
ests/constructor-01.glsl
ests/constructor-02.glsl
ests/constructor-03.glsl
ests/constructor-04.glsl
ests/constructor-05.glsl
ests/constructor-06.glsl
ests/constructor-07.glsl
ests/constructor-08.glsl
ests/constructor-09.glsl
ests/function-01.glsl
ests/function-02.glsl
ests/function-03.glsl
ests/function-04.glsl
ests/function-05.glsl
ests/if-01.glsl
ests/if-02.glsl
ests/if-03.glsl
ests/if-04.glsl
ests/matrix-01.glsl
ests/matrix-02.glsl
ests/matrix-03.glsl
ests/matrix-04.glsl
ests/matrix-05.glsl
ests/matrix-06.glsl
ests/matrix-07.glsl
ests/matrix-08.glsl
ests/matrix-09.glsl
ests/matrix-10.glsl
ests/parameters-01.glsl
ests/parameters-02.glsl
ests/parameters-03.glsl
ests/qualifier-01.glsl
ests/qualifier-02.glsl
ests/qualifier-03.glsl
ests/qualifier-04.glsl
ests/qualifier-05.glsl
ests/qualifier-06.glsl
ests/qualifier-07.glsl
ests/swiz-01.glsl
ests/swiz-02.glsl
ests/void-01.glsl
8be58df67a3d3cc682407f10badcb92a1c988e65 02-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> scons: Use Flex and Bison to generate lexer/parser files.

This gets it building again here; I'll leave it up to the SCons
maintainers to make further improvements.
Conscript
80ec97af79530dc053770d218cd55ac7dbd74736 02-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Rename .lpp to .ll and .ypp to .yy.

SCons has built-in support for .ll and .yy, but not .lpp and .ypp. Since
there's no real benefit to using the old names, change them.
akefile
lsl_lexer.ll
lsl_lexer.lpp
lsl_parser.ypp
lsl_parser.yy
6dd0a2ed40309fe721eb1c6f8217d363b3a57f04 12-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> Add generated parser / lexer files to gitignore lists
gitignore
lcpp/.gitignore
cb48207e4bb85db636ea5201c8f0657bae202f59 01-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> glcpp: Remove files generated by flex and bison from GIT
lcpp/glcpp-lex.c
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
8864b38783b5c907aea3e2d96112e5205f1de2a4 01-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Remove files generated by flex and bison from GIT
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
0a163cf56d1e412629cb802480998a982a47bb3c 26-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Enable GL_OES_texture_3D extension for ES2.
uiltin_types.h
uiltins/profiles/OES_texture_3D.frag
uiltins/profiles/OES_texture_3D.vert
lsl_parser_extras.cpp
lsl_parser_extras.h
lsl_types.cpp
lsl_types.h
eb639349e289a6b8be06a54f5e9e0ce18c71d511 27-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Use reralloc instead of plain realloc.

Plugs a memory leak when compiling shaders with user defined structures.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
a385ac62070fa68052c77df7be62685bf6a58992 26-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Fix return type for textureSize sampler2DArray variants.

A copy and paste error.
uiltins/profiles/130.frag
uiltins/profiles/130.vert
99b9019716d0a5cfc7438677d2e11090d676c054 26-Feb-2011 Arkadiusz Miskiewicz <arekm@maven.pl> glsl/Makefile: Remove builtin_function.cpp if generation fails.

Fixes bug #34346.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
497baf4e4a6a0a2f247c7bfb9bf69a2b93c2c19f 10-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> Use C-style system headers in C++ code to avoid issues with std:: namespace
st_expr.cpp
st_type.cpp
lsl_parser_extras.h
lsl_types.cpp
lsl_types.h
ir_field_selection.cpp
r.h
r_import_prototypes.cpp
r_print_visitor.cpp
r_validate.cpp
ink_functions.cpp
inker.cpp
oop_controls.cpp
ower_mat_op_to_vec.cpp
ain.cpp
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_dead_code.cpp
pt_dead_code_local.cpp
pt_dead_functions.cpp
pt_structure_splitting.cpp
pt_swizzle_swizzle.cpp
pt_tree_grafting.cpp
_expression.cpp
b1002e4aa50a634f5663eb416e9a0a582fb95633 19-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove $(PWD) from Makefile in favor of .

Hopefully should fix bug #34468.
akefile
25b36e8ff81a9c951085d6dd802a7534db476f5a 16-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Fix off-by-one error implicit array sizing

Arrays are zero based. If the highest element accessed is 6, the
array needs to have 7 elements.

Fixes piglit test glsl-fs-implicit-array-size-03 and bugzilla #34198.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
inker.cpp
62c8c773334c1b0cdd484997a4ccec8945713f8c 14-Feb-2011 Chad Versace <chad.versace@intel.com> glsl: Reinstate constant-folding for division by zero

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.
r_constant_expression.cpp
f2e9981e43b26ca101b774ea6af1f00617098246 14-Feb-2011 Chad Versace <chad.versace@intel.com> Revert "glsl: Fix constant-folding for reciprocal expressions"

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.
r_constant_expression.cpp
d1e28b22673777fe1290cda899abf73aad02e4aa 03-Feb-2011 Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> mesa: Optionally build a dricore support library (v3)

This an adds --enable-shared-dricore option to configure. When enabled,
DRI modules will link against a shared copy of the common mesa routines
rather than statically linking these.

This saves about 30MB on disc with a full complement of classic DRI
drivers.

v2: Only enable with a gcc-compatible compiler that handles rpath
Handle DRI_CFLAGS without filter-out magic
Build shared libraries with the full mklib voodoo
Fix typos
v3: Resolve conflicts with talloc removal patches

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
akefile
a0120e6e0f4fbf11a43725862a03f8dc6904bc4b 12-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> glcpp: regerated files

These should have been committed right after fd1252ab, but they were
missed. Soon, we'll never have to do this again...
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
afdceede5565eb6aa9752aed41a2023eb04a8df8 28-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Regenerate files modified by previous commits
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
884215894493bdbc55abd567c121c9df06ae3bc7 28-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Finish out the reduce/reduce error fixes

Track variables, functions, and types during parsing. Use this
information in the lexer to return the currect "type" for identifiers.

Change the handling of structure constructors. They will now show up
in the AST as constructors (instead of plain function calls).

Fixes piglit tests constructor-18.vert, constructor-19.vert, and
constructor-20.vert. Also fixes bugzilla #29926.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_function.cpp
lsl_lexer.lpp
lsl_parser.ypp
f4b812e1a661448cf4b624f283c949a54b52e9d5 08-Oct-2010 Keith Packard <keithp@keithp.com> glsl: Eliminate reduce/reduce conflicts in glsl grammar

This requires lexical disambiguation between variable and type
identifiers (as most C compilers do).

Signed-off-by: Keith Packard <keithp@keithp.com>

NOTE: This is a candidate for the 7.9 and 7.10 branches.
lsl_parser.ypp
982609f4cf2afc4e0afd450aa24907986bca41ab 11-Feb-2011 José Fonseca <jfonseca@vmware.com> scons: builtin_glsl_function on windows needs bundled getopt.
Conscript
ae760279f142244590c8aa76e3139529ca42952f 11-Feb-2011 José Fonseca <jfonseca@vmware.com> scons: Try to support building 64bit binaries on 32bit windows.
Conscript
11f35aa418b15da61147dc8bffe65745d3017f82 11-Feb-2011 Tobias Jakobi <liquid.acid@gmx.net> glsl: Fix parallel build.

Broken since e0c1fc32832b66b52e6352ba563288ee48a1face.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
e0c1fc32832b66b52e6352ba563288ee48a1face 11-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/Makefile: glcpp doesn't need libglsl.a.

Also, add a 'glcpp' target so you can type 'make glcpp' instead of
'make glcpp/glcpp'.
akefile
60aab5f335537e5b6788132e2563865243483750 08-Feb-2011 Eric Anholt <eric@anholt.net> glsl: Disable the new copy propagation pass until it gets fixed.

It apparently regressed a bunch of ES2 cases.
lsl_parser_extras.cpp
82f994f3860ca05ff5550f32844b0f523d40b9ef 04-Feb-2011 Chad Versace <chad.versace@intel.com> glsl: Set operators '%' and '%=' to be reserved when GLSL < 1.30

From section 5.9 of the GLSL 1.20 spec:
The operator modulus (%) is reserved for future use.

From section 5.8 of the GLSL 1.20 spec:
The assignments modulus into (%=), left shift by (<<=), right shift by
(>>=), inclusive or into ( |=), and exclusive or into ( ^=). These
operators are reserved for future use.

The GLSL ES 1.00 spec and GLSL 1.10 spec have similiar language.

Fixes bug:
https://bugs.freedesktop.org//show_bug.cgi?id=33916

Fixes Piglit tests:
spec/glsl-1.00/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.00/compiler/assignment-operators/modulus-assign-00.frag
spec/glsl-1.10/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.10/compiler/assignment-operators/modulus-assign-00.frag
spec/glsl-1.20/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.20/compiler/assignment-operators/modulus-assign-00.frag
st_to_hir.cpp
ce9171f9d8e0e2c2422fdddb198f8d548381b7ea 04-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Generate link errors when ES shaders are missing stages

ES requires that a vertex shader and a fragment shader be present.

Fixes bugzilla #32214.
inker.cpp
425ba198321b06b8c399812210228a42b4dd9fc7 04-Feb-2011 Vinson Lee <vlee@vmware.com> glsl: Add opt_copy_propagation_elements.cpp to SConscript.

Fixes SCons build.
Conscript
29a2e9133e415de8b010df5b80db758aaf1007a6 29-Jan-2011 Eric Anholt <eric@anholt.net> glsl: Remove extra checks for constant true assignment conditions.

These are already stripped by opt_constant_folding.cpp.
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_copy_propagation.cpp
pt_copy_propagation_elements.cpp
pt_dead_code_local.cpp
b6d49ab843ff7ee989e99bb28a36eb53f704c879 29-Jan-2011 Eric Anholt <eric@anholt.net> glsl: Fix a comment typo in copy propagation.
pt_copy_propagation.cpp
e31266ed3e3667c043bc5ad1abd65cfdb0fa7fdb 25-Jan-2011 Eric Anholt <eric@anholt.net> glsl: Add a new opt_copy_propagation variant that does it channel-wise.

This patch cleans up many of the extra copies in GLSL IR introduced by
i965's scalarizing passes. It doesn't result in a statistically
significant performance difference on nexuiz high settings (n=3) or my
demo (n=10), due to brw_fs.cpp's register coalescing covering most of
those extra moves anyway. However, it does make the debug of wine's
GLSL shaders much more tractable, and reduces instruction count of
glsl-fs-convolution-2 from 376 to 288.
akefile
lsl_parser_extras.cpp
r_optimization.h
pt_copy_propagation_elements.cpp
cde443e0b94ec6d8d0a99284e72ca7f9e2591174 04-Feb-2011 Vinson Lee <vlee@vmware.com> ralloc: Add missing va_end following va_copy.
alloc.c
61c59234f916406512b3591f46599cc29a5d8e23 04-Feb-2011 Vinson Lee <vlee@vmware.com> glsl: Add using statements for standard library functions.

Standard library functions in C++ are in the std namespace. When using
C++-style header files for the standard library, some compilers, such as
Sun Studio, provide symbols only for the std namespace and not for the
global namespace.

This patch adds using statements for standard library functions. Another
option could have been to prepend standard library function calls with
'std::'.

This patch fixes several compilation errors with Sun Studio.
st_expr.cpp
st_type.cpp
ir_field_selection.cpp
r_print_visitor.cpp
r_validate.cpp
ower_mat_op_to_vec.cpp
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_dead_code.cpp
pt_dead_code_local.cpp
pt_dead_functions.cpp
pt_structure_splitting.cpp
pt_swizzle_swizzle.cpp
pt_tree_grafting.cpp
fd1252ab67abb1ea351195e192429f292667a8a2 02-Feb-2011 Chad Versace <chad.versace@intel.com> glcpp: Raise error when modulus is zero

For example, this now raises an error:
#define XXX 1 / 0

Fixes bug: https://bugs.freedesktop.org//show_bug.cgi?id=33507
Fixes Piglit test: spec/glsl-1.10/preprocessor/modulus-by-zero.vert

NOTE: This is a candidate for the 7.9 and 7.10 branches.
lcpp/glcpp-parse.y
e7c1f058d18f62aa4871aec623f994d7b68cb8c1 01-Feb-2011 Chad Versace <chad.versace@intel.com> glsl: Avoid division-by-zero during constant-folding

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.
r_constant_expression.cpp
b3cf92aa916ee0537ee37723c23a9897ac9cd3e0 01-Feb-2011 Chad Versace <chad.versace@intel.com> glsl: Fix constant-folding for reciprocal expressions

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.
r_constant_expression.cpp
dfdb9fda826bb6c5dac2c55d9efcd1644a0dd2b9 02-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix use of uninitialized values in _mesa_glsl_parse_state ctor.

This has probably existed since e5e34ab18eeaffa465 or so.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
uiltins/tools/generate_builtins.py
cfd8d45ccde3252fd9a27fe0b2031a35f437a6a2 02-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix invalid use of ralloc_asprintf in prototype_string.

This was my mistake when converting from talloc to ralloc. I was
confused because the other calls in the function are to asprintf_append
and the original code used str as the context rather than NULL.

Fixes bug #33823.
st_function.cpp
3c701f1d61b33a5ffaddd4199ac277da8e287f30 01-Feb-2011 José Fonseca <jfonseca@vmware.com> glsl: Fix printf_length() on MSVC.
alloc.c
a7d350790b4d0416117bc785aa77de52e9298a01 01-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix memory error when creating the supported version string.

Passing ralloc_vasprintf_append a 0-byte allocation doesn't work. If
passed a non-NULL argument, ralloc calls strlen to find the end of the
string. Since there's no terminating '\0', it runs off the end.

Fixes a crash introduced in 14880a510a1a288df0778395097d5a52806abfb0.
lsl_parser_extras.cpp
3ef397dafc80278d48d1385e14d4e500a86e94ac 01-Feb-2011 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Fix a warning about mixed tabs/spaces.
uiltins/tools/texture_builtins.py
5e19b5ad16b2761fe9d8877318f2fc97b229335c 01-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Refresh autogenerated lexer and parser files.

For the previous commit.
lsl_parser.cpp
14880a510a1a288df0778395097d5a52806abfb0 01-Feb-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Reject shader versions not supported by the implementation

Previously we'd happily compile GLSL 1.30 shaders on any driver. We'd
also happily compile GLSL 1.10 and 1.20 shaders in an ES2 context.
This has been a long standing FINISHME in the compiler.

NOTE: This is a candidate for the 7.9 and 7.10 branches
lsl_parser.ypp
lsl_parser_extras.cpp
lsl_parser_extras.h
e5e34ab18eeaffa465094f6281dfe293b84376db 31-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Ensure that all GLSL versions are supported in the stand-alone compiler

NOTE: This is a candidate for the 7.9 and 7.10 branches
ain.cpp
bf9850db2221384f1b92b034391f7149c74bf10e 28-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix dependencies / linkage for glsl_compiler
akefile
a1f5c46d24ed9952d5643364d2814425002b5690 31-Jan-2011 Brian Paul <brianp@vmware.com> glsl: regerated files
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
aacd07d623d60356cfad9f96a261310e12eed7c0 31-Jan-2011 Brian Paul <brianp@vmware.com> glsl: make _token_list_is_empty_ignoring_space() static

To silence warning about missing prototype.
lcpp/glcpp-parse.y
3b8c7d70b392c4110fd00f8efc3d10adf1db2f0c 31-Jan-2011 Brian Paul <brianp@vmware.com> scons/glsl: add top-level 'include' dir to CPPPATH

To avoid using the /usr/include/GL/gl.h file which may be lacking
some special #defines.
Conscript
59c957b688651a4c7fa4660ee7a404bd83e8bb0b 31-Jan-2011 Brian Paul <brianp@vmware.com> glsl: add cast to silence signed/unsigned comparison warning
st_function.cpp
3ae7aa340305dbfa703abc9ec53ebad3ab6afa11 31-Jan-2011 José Fonseca <jfonseca@vmware.com> glsl: Define va_copy on MSVC.
alloc.c
ca418cbde6377dd723c857582db2f8f3725ffdea 09-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Uncomment prototypes for texture*Offset functions.
uiltins/profiles/130.frag
uiltins/profiles/130.vert
ba3de801ecb54bf980c338ef4f54097ca4ea60ee 09-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Generate texture*Offset functions.
uiltins/tools/texture_builtins.py
4c63f2de2fdac3cedef65eb29f57e6e2b26a0d59 27-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Generalize the "use_proj" field to support offsets.

Rather than passing "True", pass a bitfield describing the particular
variant's features - either projection or offset.

This should make the code a bit more readable ("Proj" instead of "True")
and make it easier to support offsets in the future.
uiltins/tools/texture_builtins.py
99f36486ebf3d5a6edfd6329e882d6409a085582 27-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Refactor coordinate dimension calculations.

For offsets, we'll want the straight sampler dimensionality, without the
+1 for array types. Create a new function to do that; refactor.
uiltins/tools/texture_builtins.py
819d57fce94b20fa0d34da6f037f0a53c4a5bdc2 13-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Introduce a new "const_in" variable mode.

This annotation is for an "in" function parameter for which it is only legal
to pass constant expressions. The only known example of this, currently,
is the textureOffset functions.

This should never be used for globals.
st_function.cpp
r.cpp
r.h
r_function.cpp
r_print_visitor.cpp
r_reader.cpp
r_variable.cpp
inker.cpp
ower_variable_index_to_cond_assign.cpp
pt_constant_folding.cpp
pt_function_inlining.cpp
pt_tree_grafting.cpp
c5a27b5939427bdc95c926b450ed3de1ff4baafb 09-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Change texel offsets to a single vector rvalue.

Having these as actual integer values makes it difficult to implement
the texture*Offset built-in functions, since the offset is actually a
function parameter (which doesn't have a constant value).

The original rationale was that some hardware needs these offset baked
into the instruction opcode. However, at least i965 should be able to
support non-constant offsets. Others should be able to rely on inlining
and constant propagation.
uiltins/tools/texture_builtins.py
r.h
r_clone.cpp
r_hv_accept.cpp
r_print_visitor.cpp
r_reader.cpp
r_rvalue_visitor.cpp
pt_tree_grafting.cpp
60c8e91c795dc604c08977d5773f96a4de8e402b 31-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Re-synchronize ir_variable_mode and the printer's string array.

Since the introduction of ir_var_system_value, system variables would be
printed as "temporary" and temporaries would result in out-of-bounds
array access, showing up as garbage in printed IR.
r_print_visitor.cpp
8aac5d123c4636fad5e9d70c3a6706aaa6f1f240 24-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> Remove talloc from the SCons build system.
Conscript
d1d8120545b0bd2f7ec48c5f03c77b967b082e04 17-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> Remove talloc from the make and automake build systems.
akefile
42fd9c2ebb8a9eecf69d6a7a2bc0d778f49285de 22-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> ralloc: a new MIT-licensed recursive memory allocator.
alloc.c
alloc.h
d3073f58c17d8675a2ecdd5dfa83e5520c78e1a8 21-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> Convert everything from the talloc API to the ralloc API.
st.h
st_function.cpp
st_to_hir.cpp
uiltins/tools/generate_builtins.py
lcpp/glcpp-lex.c
lcpp/glcpp-lex.l
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
lcpp/glcpp.c
lcpp/glcpp.h
lcpp/pp.c
lsl_lexer.cpp
lsl_lexer.lpp
lsl_parser.cpp
lsl_parser.ypp
lsl_parser_extras.cpp
lsl_parser_extras.h
lsl_symbol_table.cpp
lsl_symbol_table.h
lsl_types.cpp
lsl_types.h
r.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_expression_flattening.cpp
r_import_prototypes.cpp
r_reader.cpp
r_validate.cpp
r_variable_refcount.h
inker.cpp
ist.h
oop_analysis.cpp
oop_controls.cpp
oop_unroll.cpp
ower_discard.cpp
ower_if_to_cond_assign.cpp
ower_mat_op_to_vec.cpp
ower_noise.cpp
ower_texture_projection.cpp
ower_variable_index_to_cond_assign.cpp
ower_vec_index_to_cond_assign.cpp
ower_vec_index_to_swizzle.cpp
ower_vector.cpp
ain.cpp
pt_algebraic.cpp
pt_constant_propagation.cpp
pt_copy_propagation.cpp
pt_dead_code_local.cpp
pt_dead_functions.cpp
pt_function_inlining.cpp
pt_structure_splitting.cpp
_expression.cpp
_expression.h
dc55254f5b23e5ad7a07c974ce772f93b4c11cb0 16-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> ralloc: Add a fake implementation of ralloc based on talloc.
akefile
Conscript
alloc.c
alloc.h
2a18d1950c84c96d263cc8f15434502e03aeb1dc 28-Jan-2011 Carl Worth <cworth@cworth.org> Revert "glcpp: Demote "macro redefined" from an error to a warning"

This reverts commit d3df641f0aba99b0b65ecd4d9b06798bca090a29.

The original commit had sat unpushed on my machine for months. By the
time I found it again, I had forgotten that we had decided not to use
this change after all, (the relevant test was removed long ago).
lcpp/README
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
lcpp/tests/089-redefine-macro-error.c.expected
d3df641f0aba99b0b65ecd4d9b06798bca090a29 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Demote "macro redefined" from an error to a warning

The GLSL specification is vague here, (just says "as is standard for
C++"), though the C specifications seem quite clear that this should
be an error.

However, an existing piglit test (CorrectPreprocess11.frag) expects
this to be a warning, not an error, so we change this, and document in
README the deviation from the specification.
lcpp/README
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
lcpp/tests/089-redefine-macro-error.c.expected
67c67ee80fd00c033561ffc32d0fed671db36302 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Refresh autogenerated lexer file

For previous commit.
lsl_lexer.cpp
cc4a787044ac2b1616a982f6efde4a0cb7542304 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Remove extraneously extraneous parens

I found this parenthetical usage of parentheses to be extraneously
extraneous:
(yyextra->ARB_fragment_coord_conventions_enable)
lsl_lexer.lpp
8ba260e09910d6906fba17a78eee6d1b0cf8069d 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Enable AMD_conservative_depth in parser

All the necessary compiler infrastructure for AMD_conservative_depth is in
place, so it's safe to enable it in the parser.
lsl_parser_extras.cpp
addae33d6b8574971b82283ab890524480054a1d 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Raise linking error if gl_FragDepth layout is inconsistent

From the AMD_conservative_depth spec:
If gl_FragDepth is redeclared in any fragment shader in a program, it
must be redeclared in all fragment shaders in that program that have
static assignments to gl_FragDepth. All redeclarations of gl_FragDepth in
all fragment shaders in a single program must have the same set of
qualifiers.
inker.cpp
bc04d244f5a86fd7085e3d648949413e2d2ec797 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Propagate depth layout qualifier from AST to IR
st_to_hir.cpp
r.cpp
r.h
5fc57f471b10e74546f999269a2a8f9186da9731 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Define enum ir_depth_layout
r.cpp
r.h
39cad66a889b453d78e83e6a20560bcc338000de 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Refresh autogenerated parser files

For commits titled:
glcpp: Conditionally define macro GL_AMD_conservative_depth
glsl: Add support for AMD_conservative_depth to parser
lcpp/glcpp-parse.c
lsl_lexer.cpp
lsl_parser.cpp
fb5db0570cad458232ad61b7af39622bacbe9af6 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Add support for AMD_conservative_depth to parser

When AMD_conservative_depth is enabled:
* Let 'layout' be a token.
* Extend the production rule of layout_qualifier_id to process the tokens:
depth_any
depth_greater
depth_less
depth_unchanged
lsl_lexer.lpp
lsl_parser.ypp
lsl_parser_extras.h
565a22090c3f143a343c19249a92be6a84b291b0 27-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Add depth layout qualifiers to ast_type_qualifier
st.h
0423f24eb8a415cf704c307c93e2a8647e799002 27-Jan-2011 Chad Versace <chad.versace@intel.com> glcpp: Conditionally define macro GL_AMD_conservative_depth

Define macro GL_AMD_conservative_depth to 1 when its extension is
enabled.
lcpp/glcpp-parse.y
0f4b2a0a23650d8f773c53d84cb2ead1f6d4fc8e 25-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Propagate max_array_access while linking functions

Update the max_array_access of a global as functions that use that
global are pulled into the linked shader.

Fixes piglit test glsl-fs-implicit-array-size-01 and bugzilla #33219.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
ink_functions.cpp
inker.cpp
c87e9ef4d291b3fc18f7af2c7a7646b9a860f4af 25-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> linker: Set sizes for non-global arrays as well

Previously only global arrays with implicit sizes would be patched.
This causes all arrays that are actually accessed to be sized.

Fixes piglit test glsl-fs-implicit-array-size-02.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
inker.cpp
9f2bf3d65cf0745a34185c1966d52389fbd1ca90 25-Jan-2011 Brian Paul <brianp@vmware.com> glsl: silence uninitialized var warning in read_texture()

And generate an error if the texture pattern is not matched.
r_reader.cpp
4fabdf72eaa108382216222a1e455fd7ab9b027b 24-Jan-2011 Jakob Bornecrantz <jakob@vmware.com> glsl: Fix mingw crosscompile
Conscript
e0c4a59dc6c415c2abf6e0c5e3aaf5aee781cdf1 24-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove long unused 'configure.ac' file.

This was from way back when glsl2 lived in its own repository.
onfigure.ac
2db46fe5f0145a6afff5b8edc2f00b8c734bb640 23-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Don't assert when the value returned by a function has no rvalue

The rvalue of the returned value can be NULL if the shader says
'return foo();' and foo() is a function that returns void.

Existing GLSL specs do *NOT* say that this is an error. The type of
the return value is void. If the return type of the function is also
void, then this should compile without error. I expect that future
versions of the GLSL spec will fix this (wink, wink, nudge, nudge).

Fixes piglit test glsl-1.10/compiler/expressions/return-01.vert and
bugzilla #33308.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
0db3161036f47447d72eebe26869779e264b3c8a 16-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Regenerate parser files.
lcpp/glcpp-parse.c
6ecee54a9aecc120cb68b02f7e14dcac86b9eca2 16-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove use of talloc reference counting.

We almost always want to simply steal; we only need to copy when copying
a token list (in which case we're already cloning stuff anyway).
lcpp/glcpp-parse.y
e256e4743c3f8f924f0d191759d9428f33f3e329 19-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl, i965: Remove unnecessary talloc includes.

These are already picked up by ir.h or glsl_types.h.
r_reader.cpp
ink_functions.cpp
inker.cpp
b66be7518ad57368b31b5d70a2bb4c0fe66aa988 21-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Improve error message when read-only vars are written

Improves the cases when:
* an explicit assignment references the read-only variable
* an 'out' or 'inout' function parameter references the read-only variable
st_function.cpp
st_to_hir.cpp
01a584d09350d2c726312e2c9e88c5dbc54bdb70 20-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Mark 'in' variables at global scope as read-only

Fixes Piglit tests:
spec/glsl-1.30/compiler/storage-qualifiers/static-write-centroid-in-01.frag
spec/glsl-1.30/compiler/storage-qualifiers/static-write-in-01.frag
spec/glsl-1.30/compiler/storage-qualifiers/static-write-in-02.frag
st_to_hir.cpp
f633b993b0d11cbc2880707405cf38201a5df61d 19-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Remove unused class ast_declaration_statment
st.h
aec19381ecef7d98211910709429e0077e82ef87 17-Jan-2011 twied <twied@gmx.net> Add machine generated files to .gitignore
gitignore
21031b4e887a4bd5563130d54a11972b69cb2645 16-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't bother unsetting a destructor that was never set.

This was totally copied and pasted from glsl_symbol_table.
lsl_symbol_table.cpp
46f7105df487c91569f7e4a8da74d673c12e5619 19-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Fix segfault due to missing printf argument

Fixes the following Piglit tests:
glslparsertest/shaders/array2.frag
glslparsertest/shaders/dataType6.frag

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
45e8e6c6b1b7f3bc00a578fa6809c9bc719c171a 18-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Fix semantic checks on precision qualifiers

The check for
Precision qualifiers only apply to floating point and integer types.
was incomplete. It rejected only type 'bool' and structures.
st_to_hir.cpp
58c988ada56114b56477983f66b4039219f1a82c 18-Jan-2011 Eric Anholt <eric@anholt.net> glsl: Skip the rest of loop unrolling if no loops were found.

Shaves 1.6% (+/- 1.0%) off of ff_fragment_shader glean texCombine time
(n=5).
lsl_parser_extras.cpp
oop_analysis.cpp
oop_analysis.h
a54e2de4bbbc052c86d3a43f2affad03ad54d6de 17-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Refresh autogenerated parser files
lsl_parser.cpp
lsl_parser.h
a9bf8c12ee5cad398b77b7e7767ad6ef789ce877 17-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Remove redundant semantic check in parser

The removed semantic check also exists in ast_type_specifier::hir(), which
is a more natural location for it.

The check verified that precision statements are applied only to types
float and int.
lsl_parser.ypp
08a286c9cc8fecb081057e0f551c88a446c47b6f 17-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Add support for default precision statements

* Add new field ast_type_specifier::is_precision_statement.
* Add semantic checks in ast_type_specifier::hir().
* Alter parser rules accordingly.
st.h
st_to_hir.cpp
st_type.cpp
lsl_parser.ypp
889e1a5b6c6602198d649ea5881e0010dec575e9 17-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Add semantic checks for precision qualifiers

* Check that precision qualifiers only appear in language versions 1.00,
1.30, and later.
* Check that precision qualifiers do not apply to bools and structs.

Fixes the following Piglit tests:
* spec/glsl-1.30/precision-qualifiers/precision-bool-01.frag
* spec/glsl-1.30/precision-qualifiers/precision-struct-01.frag
* spec/glsl-1.30/precision-qualifiers/precision-struct-02.frag
st_to_hir.cpp
33279cd2d33a3f3804e4584f9134f4cc67567a54 17-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Fix parser rule for type_specifier

Do not assign a value to ast_type_specifier::precision when no precision
qualifier is present.
lsl_parser.ypp
aaa31bf8f44e1aab0e87160661196b0a16e1d015 14-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Change default value of ast_type_specifier::precision

Change default value to ast_precision_none, which denotes the absence of
a precision of a qualifier.

Previously, the default value was ast_precision_high. This made it
impossible to detect if a precision qualifier was present or not.
st.h
st_type.cpp
1eb0f17fa4aa548779cb7d8ffbd86de3523d6796 12-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Check that 'centroid in' does not occur in vertex shader

The check is performed only in GLSL versions >= 1.30.

From section 4.3.4 of the GLSL 1.30 spec:
"It is an error to use centroid in in a vertex shader."

Fixes Piglit test
spec/glsl-1.30/compiler/storage-qualifiers/vs-centroid-in-01.vert
st_to_hir.cpp
8faaa4a672c1062e486eda2525287715b554342d 12-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Check that interpolation quals only apply to vertex ins and fragment outs

The check is performed only in GLSL versions >= 1.30.

Fixes the following Piglit tests:
* spec/glsl-1.30/compiler/interpolation-qualifiers/fs-smooth-02.frag
* spec/glsl-1.30/compiler/interpolation-qualifiers/vs-smooth-01.vert
st_to_hir.cpp
605aacc67d73db0926e0046a90a07fcd93a2d613 12-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Check that interpolation qualifiers do not precede 'varying'

... and 'centroid varying'. The check is performed only in GLSL
versions >= 1.30.

From page 29 (page 35 of the PDF) of the GLSL 1.30 spec:
"interpolation qualifiers may only precede the qualifiers in, centroid
in, out, or centroid out in a declaration. They do not apply to the
deprecated storage qualifiers varying or centroid varying."

Fixes Piglit test
spec/glsl-1.30/compiler/interpolation-qualifiers/smooth-varying-01.frag.
st.h
st_to_hir.cpp
st_type.cpp
0e2f8936c8ef872cb464e54a9f09ae0324487147 12-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: Add method ast_type_qualifier::interpolation_string()

If an interpolation qualifier is present, then the method returns that
qualifier's string representation. For example, if the noperspective bit
is set, then it returns "noperspective".
st.h
st_type.cpp
652901e95b4ed406293d0e1fabee857c054119b1 15-Jan-2011 Brian Paul <brianp@vmware.com> Merge branch 'draw-instanced'

Conflicts:
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/glsl/ir_set_program_inouts.cpp
src/mesa/tnl/t_vb_program.c
d42acef139740a54fe571f99b62cba7720734d8c 15-Jan-2011 Brian Paul <brianp@vmware.com> glsl: fix implicit int to bool warning

Maybe preprocess() should return a bool.
ain.cpp
57ef69dd8864a745453e4e579b22aea950fdbabb 14-Jan-2011 Vinson Lee <vlee@vmware.com> generate_builtins.py: Whitespace fixes.

Also removed unnecessary semicolons.
uiltins/tools/generate_builtins.py
0de6d7e99195b6e739e3a80482ad7860c14bef3b 14-Jan-2011 Vinson Lee <vlee@vmware.com> generate_builtins.py: Fix builds using Python 2.5.
uiltins/tools/generate_builtins.py
4bcff0c19091c7df2b2e0bafe58addb5bae28f1a 08-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Emit errors or warnings when 'layout' is used with 'attribute' or 'varying'

The specs that add 'layout' require the use of 'in' or 'out'.
However, a number of implementations, including Mesa, shipped several
of these extensions allowing the use of 'varying' and 'attribute'.
For these extensions only a warning is emitted.

This differs from the behavior of Mesa 7.10. Mesa 7.10 would only
accept 'attribute' with 'layout(location)'. This behavior was clearly
wrong. Rather than carrying the broken behavior forward, we're just
doing the correct thing.

This is related to (piglit) bugzilla #31804.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
82c4b4f88af97395a3d1b01e1998ec828cd5d305 08-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Allow 'in' and 'out' when 'layout' is also available

All of the extensions that add the 'layout' keyword also enable (and
required) the use of 'in' and 'out' with shader globals.

This is related to (piglit) bugzilla #31804.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
e1bc68b0140fef465cda26b74602aeb1cbcfdafc 13-Jan-2011 José Fonseca <jfonseca@vmware.com> scons: Fix cross-compilation.

Hairy stuff. Don't know how to do it better though.
Conscript
47b2af2c62fec3ac0fb501a31e93fc8d00c18cb8 01-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/s_expression: Read and ignore Scheme-style comments.

A single-semicolon until the end of the line, i.e.
; this is a comment.
_expression.cpp
5bfb68cd0f1d2941645a1fe133ffe1c6a4f5786b 01-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Remove unnecessary (constant bool (1)) from assignments.

This isn't strictly necessary, but is definitely nicer.
uiltins/ir/atan
uiltins/ir/distance
uiltins/ir/matrixCompMult
uiltins/ir/modf
uiltins/ir/noise2
uiltins/ir/noise3
uiltins/ir/noise4
uiltins/ir/outerProduct
uiltins/ir/refract
uiltins/ir/smoothstep
uiltins/ir/step
uiltins/ir/transpose
bbafd2b849629d3155fe0eef655bbc166a901925 01-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Make assignment conditions optional.

You can now simply write (assign (xy) <lhs> <rhs>) instead of the
verbose (assign (constant bool (1)) (xy) <lhs> <rhs>).
r_print_visitor.cpp
r_reader.cpp
b74ff382a42bcb81bbf0dc6a85bb38404c46260d 01-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Convert to a class.

This makes it unnecessary to pass _mesa_glsl_parse_state around
everywhere, making at least the prototypes a lot easier to read.

It's also more C++-ish than a pile of static C functions.
r_reader.cpp
ec7e4f0ec5c9b718bbfa33a706149030be86d2d9 31-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Combine the three dereference reading functions into one.

These used to be more complicated, but now are so simple there's no real
point in keeping them separate.
r_reader.cpp
e486fca2d3b430065cbcb27c5d1b545642e11ab5 31-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Relax requirement that function arguments be s_lists.

All of these functions used to take s_list pointers so they wouldn't all
need SX_AS_LIST conversions and error checking. However, the new
pattern matcher conveniently does this for us in one centralized place.

So there's no need to insist on s_list. Switching to s_expression saves
a bit of code and is somewhat cleaner.
r_reader.cpp
d7988152722cd5f3930064a139b567cbcb0e5f53 31-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Remove s_list::length() method.

Most code now relies on the pattern matcher rather than this function,
and for the only remaining case, not using this saves an iteration.
r_reader.cpp
_expression.cpp
_expression.h
daeb0c646e0d652bfa16d326028753ecf092c0c9 03-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Add a pattern matching system and use it everywhere.

Previously, the IR reader was riddled with code that:
1. Checked for the right number of list elements (via a linked list walk)
2. Retrieved references to each component (via ->next->next pointers)
3. Downcasted as necessary to make sure that each sub-component was the
right type (i.e. symbol, int, list).
4. Checking that the tag (i.e. "declare") was correct.

This was all very ad-hoc and a bit ugly. Error checking had to be done
at both steps 1, 3, and 4. Most code didn't even check the tag, relying
on the caller to do so. Not all callers did.

The new pattern matching module performs the whole process in a single
straightforward function call, resulting in shorter, more readable code.

Unfortunately, MSVC does not support C99-style anonymous arrays, so the
pattern must be declared outside of the match call.
r_reader.cpp
_expression.cpp
_expression.h
1b173fb3bad3b53411a4b16a385556b23a247d93 12-Jan-2011 Brian Paul <brianp@vmware.com> glsl: remove trailing comma to silence warning
ower_jumps.cpp
b076551e3bf03b9710f4d795e3490ac7ccfd5a9a 13-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl/Makefile: Fix build with --as-needed.
akefile
bd33055ef4b6dd18d6247ff7d9e47496ff4acc51 08-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Track variable usage, use that to enforce semantics

In particular, variables cannot be redeclared invariant after being
used.

Fixes piglit test invariant-05.vert and bugzilla #29164.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
r.cpp
r.h
a42906f862cbdef251fbccb69787ba3710f0116a 12-Jan-2011 Vinson Lee <vlee@vmware.com> generate_builtins.py: Add missing import.

Import sys for sys.exit.
uiltins/tools/generate_builtins.py
416ca901389b049eaaf2edbce631396772dbeb20 12-Jan-2011 José Fonseca <jfonseca@vmware.com> glsl: Make builtin_compiler build on Windows with MSVC.
Conscript
0035d1d902f34a88ec745925284fe3b768fac261 12-Jan-2011 José Fonseca <jfonseca@vmware.com> glsl: Make builtin_compiler portable for non-unices.
ain.cpp
6d670f6c0f3b9383b8b4c8ed12beaeec56928266 12-Jan-2011 José Fonseca <jfonseca@vmware.com> getopt: Import OpenBSD getopt implementation for MSVC.
Conscript
1412dea94953243b5cd3a452f676afd046101192 07-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add type inference support for remaining expression opcodes.
r.cpp
c00bc13564e432c496aa685d7b3ca7c60165be02 11-Jan-2011 Eric Anholt <eric@anholt.net> glsl: Fix the lowering of variable array indexing to not lose write_masks.

Fixes glsl-complex-subscript on 965.
ower_variable_index_to_cond_assign.cpp
33d0c44910860e0522bd56a0f8637a69e0c4a456 07-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Autogenerate builtin_functions.cpp as part of the build process.

Python is already necessary for other parts of Mesa, so there's no
reason we can't just generate it. This patch updates both make and
SCons to do so.
gitignore
akefile
Conscript
uiltin_function.cpp
uiltin_stubs.cpp
uiltins/tools/builtin_function.cpp
uiltins/tools/generate_builtins.py
469ea695bbbc984ebec26b2413ab70d450a283ca 08-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Disallow 'in' and 'out' on globals in GLSL 1.20

Fixes piglit tests glsl-1.20/compiler/qualifiers/in-01.vert and
glsl-1.20/compiler/qualifiers/out-01.vert and bugzilla #32910.

NOTE: This is a candidate for the 7.9 and 7.10 branches. This patch
also depends on the previous two commits.
st_to_hir.cpp
a0c2ec8e2dcf90709dd2e147b06a0a173611b0a1 08-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Refresh autogenerated parser file.

For the previous commit.
lsl_parser.cpp
eebdfdfbcf2721349d2c2cafe2d81fd83cade9b9 08-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Add version_string containing properly formatted GLSL version
lsl_parser.ypp
lsl_parser_extras.h
a302d740bd1e90d3db2b8cee79b2d5ee1220f8bf 11-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glcpp: Refresh autogenerated lexer and parser files.

For the previous commit.
lcpp/glcpp-parse.c
9ca5300b6e781150cec903c73cf5fd8e1deee2f1 10-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glcpp: Generate an error for division by zero

When GCC encounters a division by zero in a preprocessor directive, it
generates an error. Since the GLSL spec says that the GLSL
preprocessor behaves like the C preprocessor, we should generate that
same error.

It's worth noting that I cannot find any text in the C99 spec that
says this should be an error. The only text that I can find is line 5
on page 82 (section 6.5.5 Multiplicative Opertors), which says,

"The result of the / operator is the quotient from the division of
the first operand by the second; the result of the % operator is
the remainder. In both operations, if the value of the second
operand is zero, the behavior is undefined."

Fixes 093-divide-by-zero.c test and bugzilla #32831.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
lcpp/glcpp-parse.y
4e09a786d20ee5a2793e29d1cf336ad5383da22b 11-Jan-2011 Chad Versace <chad.versace@intel.com> glcpp: Regenerate glcpp-parse.c
lcpp/glcpp-parse.c
4fff52f1c973f2f284c142fbb31536a9656767c9 11-Jan-2011 Chad Versace <chad.versace@intel.com> glcpp: Fix segfault when validating macro redefinitions

In _token_list_equal_ignoring_space(token_list_t*, token_list_t*), add
a guard that prevents dereferncing a null token list.

This fixes test src/glsl/glcpp/tests/092-redefine-macro-error-2.c and
Bugzilla #32695.
lcpp/glcpp-parse.y
61428dd2ab66017f80dc4f3b0793e741d93a6d47 11-Jan-2011 Chad Versace <chad.versace@intel.com> glsl: At link-time, check that globals have matching centroid qualifiers

Fixes bug 31923: http://bugs.freedesktop.org/show_bug.cgi?id=31923
inker.cpp
f2d0f776b17947f2e84a82444771faa853a76b8b 06-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Refresh autogenerated lexer and parser files.

For the previous commit.
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
86b4398cd158024f6be9fa830554a11c2a7ebe0c 06-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Support the 'invariant(all)' pragma

Previously the 'STDGL invariant(all)' pragma added in GLSL 1.20 was
simply ignored by the compiler. This adds support for setting all
variable invariant.

In GLSL 1.10 and GLSL ES 1.00 the pragma is ignored, per the specs,
but a warning is generated.

Fixes piglit test glsl-invariant-pragma and bugzilla #31925.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
st_to_hir.cpp
lsl_lexer.lpp
lsl_parser.ypp
lsl_parser_extras.h
e942f328365309a1d8240cfe8eb5d88391015f37 05-Jan-2011 Ian Romanick <ian.d.romanick@intel.com> glsl: Allow less restrictive uses of sampler array indexing in GLSL <= 1.20

GLSL 1.10 and 1.20 allow any sort of sampler array indexing.
Restrictions were added in GLSL 1.30. Commit f0f2ec4d added support
for the 1.30 restrictions, but it broke some valid 1.10/1.20 shaders.
This changes the error to a warning in GLSL 1.10, GLSL 1.20, and GLSL
ES 1.00.

There are some spurious whitespace changes in this commit. I changed
the layout (and wording) of the error message so that all three cases
would be similar. The 1.10/1.20 and 1.30 text is the same. The only
difference is that one is an error, and the other is a warning. The
GLSL ES 1.00 wording is similar but not quite the same.

Fixes piglit test
spec/glsl-1.10/compiler/constant-expressions/sampler-array-index-02.frag
and bugzilla #32374.
st_to_hir.cpp
5a3f31575bf0657661c3e66a4c95c3298c78e441 05-Jan-2011 Vinson Lee <vlee@vmware.com> glcpp: Add test for recursive #define.
lcpp/tests/095-recursive-define.c
6530944b502a0f35b305ee35c1c6f1e32a887721 04-Jan-2011 Vinson Lee <vlee@vmware.com> glcpp: Add division by zero test cases.
lcpp/tests/093-divide-by-zero.c
lcpp/tests/094-divide-by-zero-short-circuit.c
68d06b1454aea30c492c7318ab4e8514df8f38fd 16-Dec-2010 Chad Versace <chad.versace@intel.com> glsl: Check that integer vertex outputs are qualified with flat

Perform this check in ast_declarator_list::hir().

From section 4.3.6 of the GLSL 1.30 spec:
"If a vertex output is a signed or unsigned integer or integer
vector, then it must be qualified with the interpolation
qualifier
flat."
st_to_hir.cpp
b84e3f570f4b5aba1dd96760e090ae976d0e1cba 16-Dec-2010 Chad Versace <chad.versace@intel.com> glsl: Allow redeclaration of gl_Color and its variants in GLSL 1.30

Allow redeclaration of the following built-in variables with an
interpolation qualifier in language versions >= 1.30:
* gl_FrontColor
* gl_BackColor
* gl_FrontSecondaryColor
* gl_BackSecondaryColor
* gl_Color
* gl_SecondaryColor

See section 4.3.7 of the GLSL 1.30 spec.
st_to_hir.cpp
4a62a1c366703c5df10fd1d96f46ecb03ce45138 16-Dec-2010 Chad Versace <chad.versace@intel.com> glsl: Comment ast_type_qualifier.flags
st.h
1d40cf57f843f555139809e91ab8c30923c57698 01-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Really remove unused "instructions" parameter.

I forgot about this file, and it didn't show up until I tried to do
"make builtins" from a clean build.
uiltins/tools/builtin_function.cpp
81168351a7f493fcde55e621af046c9301aa93e9 01-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused "instructions" parameter.

I think was used long ago, when we actually read the builtins into the
shader's instruction stream directly, rather than creating a separate
shader and linking the two. It doesn't seem to serve any purpose now.
st_to_hir.cpp
uiltin_function.cpp
uiltins/tools/generate_builtins.py
r.h
f3319561a476bd806005551251dbc6a37f266e03 28-Dec-2010 Vinson Lee <vlee@vmware.com> glcpp: Add negative tests for redefintions with valueless macros.
lcpp/tests/092-redefine-macro-error-2.c
lcpp/tests/092-redefine-macro-error-2.c.expected
9ac6a9b2fa45debac63f2e2b20d78c4776d06e37 27-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Support if-flattening beyond a given maximum nesting depth.

This adds a new optional max_depth parameter (defaulting to 0) to
lower_if_to_cond_assign, and makes the pass only flatten if-statements
nested deeper than that.

By default, all if-statements will be flattened, just like before.

This patch also renames do_if_to_cond_assign to lower_if_to_cond_assign,
to match the new naming conventions.
r_optimization.h
ower_if_to_cond_assign.cpp
a954dbeb8c422a6a800b77d5ded76c92eebde1a8 18-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated file builtin_function.cpp.

NOTE: The 7.9 and 7.10 branches will need their builtins refreshed too.
Rather than cherry-picking this commit, run 'make builtins'.
uiltin_function.cpp
d7423a653175352c5e2017f1de647bc7ef5ede43 18-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Compute the correct value for smoothstep(vec, vec, vec).

These mistakenly computed 't' instead of t * t * (3.0 - 2.0 * t).

Also, properly vectorize the smoothstep(float, float, vec) variants.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
uiltins/ir/smoothstep
5c229e5fbd8ffa573ab2c1225f182036792a75af 13-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Expose a public glsl_type::void_type const pointer.

This is analogous to glsl_type::int_type and all the others.
uiltin_types.h
lsl_types.cpp
lsl_types.h
bb10e081c8ddc452bca44ba583f239219a5b9372 13-Dec-2010 Brian Paul <brianp@vmware.com> glsl: new glsl_strtod() wrapper to fix decimal point interpretation

We always want to use '.' as the decimal point.

See http://bugs.freedesktop.org/show_bug.cgi?id=24531

NOTE: this is a candidate for the 7.10 branch.
akefile
Conscript
lsl_lexer.cpp
lsl_lexer.lpp
_expression.cpp
_expression.h
trtod.c
trtod.h
cb2b547a4771ddf56975ede566dbf3a8f5389689 14-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Allow built-in arrays to have different sizes between shader stages

Fixes pitlit test glsl-link-varying-TexCoord (bugzilla #31650).
inker.cpp
d7f27e2e76eac9bc2ee0fa36f52542fdcb9563dd 11-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Inherrit type of declared variable from initializer after processing assignment

do_assignment may apply implicit conversions to coerce the base type
of initializer to the base type of the variable being declared. Fixes
piglit test glsl-implicit-conversion-02 (bugzilla #32287). This
probably also fixes bugzilla #32273.

NOTE: This is a candidate for the 7.9 branch and the 7.10 branch.
st_to_hir.cpp
ec53010c4d02e11171d3c782a41b70cad76788e8 11-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Minor clean-up in validate_assignment

This code has been changed around a lot, and there were some temporary
variables left around from previous versions.
st_to_hir.cpp
0e50c21e247b6d4246fcc2b583563a8f44bc4249 02-Dec-2010 Luca Barbieri <luca@luca-barbieri.com> glsl: Unroll loops with conditional breaks anywhere (not just the end)

Currently we only unroll loops with conditional breaks at the end, which is
the form that lower_jumps generates.

However, if breaks are not lowered, they tend to appear at the beginning, so
add support for a conditional break anywhere.

Signed-off-by: Luca Barbieri <luca@luca-barbieri.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
oop_unroll.cpp
13c45c590b69341487acf21f339bf1e502eedee6 02-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Consider the "else" branch when looking for loop breaks.

Found this bug by code inspection. Based off the comments just before
this code, the intent is to find whether the break exists in the "then"
branch or the "else" branch. However, the code actually looked at the
last instruction in the "then" branch twice.
oop_unroll.cpp
528fa8ce329c22d6376d075c2afa69f177423bfa 02-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Clean up code by adding a new is_break() function.
oop_unroll.cpp
b13a2e640f749530d3bf40cbbc30504b1ed58470 09-Dec-2010 Eric Anholt <eric@anholt.net> glsl: Correct the marking of InputsRead/OutputsWritten on in/out matrices.

If you used a constant array index to access the matrix, we'd flag a
bunch of wrong inputs/outputs as being used because the index was
multiplied by matrix columns and the actual used index was left out.

Fixes glsl-mat-attribute.
r_set_program_inouts.cpp
ef534f3838f23d757a40426728789183ed36c3bb 01-Dec-2010 Fabian Bieler <der.fabe@gmx.net> glsl: fix lowering conditional returns in subroutines

this fix applies to the lower_sub_return 'branch' of the lower_jumps pass

Fixes piglit tests glsl-functions-5 and glsl-functions-6.
ower_jumps.cpp
f0f2ec4d8a50c79c2943ac95eb790fb734d88980 07-Dec-2010 Chad Versace <chad.versace@intel.com> glsl: In ast_to_hir, check sampler array indexing

Raise error if a sampler array is indexed with a non-constant expression.

From section 4.1.7 of the GLSL 1.30 spec:
"Samplers aggregated into arrays within a shader (using square
brackets [ ]) can only be indexed with integral constant
expressions [...]."
st_to_hir.cpp
7ce186358e881d1e30eda716a8dea73d2dab2ee9 09-Dec-2010 Brian Paul <brianp@vmware.com> glsl: add support for system values and GL_ARB_draw_instanced
lsl_parser_extras.cpp
lsl_parser_extras.h
r.h
r_set_program_inouts.cpp
r_variable.cpp
ain.cpp
002cd2c8d439729227c79093bdbf8a269e72c19f 08-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Fix regressions caused by previous commit

That's what I get for not running piglit before pushing.

Don't try to patch types of unsized arrays when linking fails.

Don't try to patch types of unsized arrays that are shared between
shader stages.
inker.cpp
6f53921c4b9dea8439a851eaa9a4df3791e5649a 08-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Ensure that unsized arrays have a size after linking

Fixes piglit test case glsl-vec-array (bugzilla #31908).

NOTE: This bug does not affect 7.9, but I think this patch is a
candiate for the 7.9 branch anyway.
inker.cpp
b0fc5103cbc9116806a9888f747baed4b8166246 08-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Inherrit type of declared variable from initializer

Types of declared variables and their initializer must match excatly
except for unsized arrays. Previously the type inherritance for
unsized arrays happened implicitly in the emitted assignment.
However, this assignment is never emitted for uniforms. Now that type
is explicitly copied unconditionally.

Fixes piglit test array-compare-04.vert (bugzilla #32035) and
glsl-array-uniform-length (bugzilla #31985).

NOTE: This is a candidate for the 7.9 branch.
st_to_hir.cpp
6d36be508ff0765beb6cf6bb95a323ff01e458dd 02-Dec-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Ensure that equality comparisons don't return a NULL IR tree

This fixes bugzilla #32035 and piglit test case array-compare-01 and
array-compare-02.

NOTE: This is a candidate for the 7.9 branch.
st_to_hir.cpp
bd74101aeb88ce409cc7204c57c173c9c4e65368 07-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated glcpp parser.
lcpp/glcpp-parse.c
800eed6765d43d35a338d3135b3204fa6a318afd 07-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Don't emit SPACE tokens in conditional_tokens production.

Fixes glslparsertest defined-01.vert.

Reported-by: José Fonseca <jfonseca@vmware.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
lcpp/glcpp-parse.y
c17c7903871b031162e41d6495a1bef64844e19b 06-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Properly add functions during lazy built-in prototype importing.

The original lazy built-in importing patch did not add the newly created
function to the symbol table, nor actually emit it into the IR stream.

Adding it to the symbol table is non-trivial since importing occurs when
generating some ir_call in a nested scope. A new add_global_function
method, backed by new symbol_table code in the previous patch, handles
this.

Fixes bug #32030.
st_function.cpp
lsl_symbol_table.cpp
lsl_symbol_table.h
6fae1e4c4d33769e2f255d50907b5aa0ab80edd4 06-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Factor out code which emits a new function into the IR stream.

A future commit will use the newly created function in a second place.
st.h
st_to_hir.cpp
b7acf538af24ddab72a5cbd5975f089a747b68e4 02-Dec-2010 Kenneth Graunke <kenneth@whitecape.org> ir_print_visitor: Print out constant structure values.

In the form (constant type ((field1 value) (field2 value) ...))
r_print_visitor.cpp
b381eff1411dea5b9e0c9fbc8641a8760052b2eb 02-Dec-2010 Eric Anholt <eric@anholt.net> glsl: Fix flipped return of has_value() for array constants.

Fixes glsl-array-uniform.
r.cpp
7528f143dfb77e3e0486006676e990964392aebf 17-Nov-2010 Chad Versace <chad.versace@intel.com> glsl: Fix linker bug in cross_validate_globals()

Cause linking to fail if a global has mismatching invariant qualifiers.

See https://bugs.freedesktop.org/show_bug.cgi?id=30261
inker.cpp
b4f585665c31b1f80d909e38b3b2a9fab0c03076 02-Dec-2010 Eric Anholt <eric@anholt.net> glsl: Mark the array access for whole-array comparisons.

By not doing so, the uniform contents of
glsl-uniform-non-uniform-array-compare.shader_test was getting thrown
out since nobody was recorded as dereferencing the array.
st_to_hir.cpp
c4285be9a5bd1adaa89050989374b95a9a601cdc 25-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Lower ir_binop_pow to a sequence of EXP2 and LOG2
r_optimization.h
ower_instructions.cpp
da61afa7388f1ce50ef612b89aba2302a052a3bb 24-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Use M_LOG2E constant instead of calling log2
ower_instructions.cpp
d2d7a273c51127677d394d1bb9484a2d85c5dcd2 29-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add comments to lower_jumps (from the commit message).

This is essentially Luca's commit message, but placed at the top of the
file.
ower_jumps.cpp
1802cb9bafc4125300870be51e8b22ddd795d61e 29-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove "discard" support from lower_jumps.

The new lower_discard and opt_discard_simplification passes should
handle all the necessary transformations, so lower_jumps doesn't need to
support it.

Also, lower_jumps incorrectly handled conditional discards - it would
unconditionally truncate all code after the discard. Rather than fixing
the bug, simply remove the code.

NOTE: This is a candidate for the 7.9 branch.
ower_jumps.cpp
940df10100d740ef27fa39026fd51c3199ed3d62 25-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add a lowering pass to move discards out of if-statements.

This should allow lower_if_to_cond_assign to work in the presence of
discards, fixing bug #31690 and likely #31983.

NOTE: This is a candidate for the 7.9 branch.
akefile
Conscript
r_optimization.h
ower_discard.cpp
9a1d063c6d679c2155f5eb80f1cb94368d36bf2c 25-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add an optimization pass to simplify discards.

NOTE: This is a candidate for the 7.9 branch.
akefile
Conscript
lsl_parser_extras.cpp
r_optimization.h
pt_discard_simplification.cpp
2da02e75b17dcfb2efc3ce053c48339109bc0f26 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/linker: Free any IR discarded by optimization passes.

Previously, IR for a linked shader was allocated directly out of the
gl_shader object - meaning all of it lived as long as the shader.

Now, IR is allocated out of a temporary context, and any -live- IR is
reparented/stolen to (effectively) the gl_shader. Any remaining IR can
be freed.

NOTE: This is a candidate for the 7.9 branch.
inker.cpp
ff994eeff8fa9f8f889878d6b48015ca7683e22b 11-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove anti-built-in hacks from the print visitor.

Now that we only import built-in signatures that are actually used,
printing them is reasonable.
r_print_visitor.cpp
f5692f452f7ae77d1e710041ffebb468cc5ba87b 11-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Lazily import built-in function prototypes.

This makes a very simple 1.30 shader go from 196k of memory to 9k.

NOTE: This -may- be a candidate for the 7.9 branch, as the benefit is
substantial. However, it's not a simple change, so it may be wiser to
wait for 7.10.
st_function.cpp
uiltin_function.cpp
uiltins/tools/generate_builtins.py
01a25bb64ecae156729794320f9a39733ff8eeaa 11-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refactor out cloning of function prototypes.

This allows us to reuse some code and will be useful later.
r.h
r_clone.cpp
r_import_prototypes.cpp
4ce084c7072931732fba7ae1d73a4e4e20269f9d 30-Nov-2010 Aras Pranckevicius <aras@unity3d.com> glsl: fix matrix type check in ir_algebraic

Fixes glsl-mat-mul-1.
pt_algebraic.cpp
d56c97413ee65e40e3544b89ffca450df9ba1c06 30-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Quiet unreachable no-return-from-function warning.
st_to_hir.cpp
ff79633d9f930e396933a0ad9564824ec73ea4dc 30-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Fix structure and array comparisions.

We were trying to emit a single ir_expression to compare the whole
thing. The backends (ir_to_mesa.cpp and brw_fs.cpp so far) expected
ir_binop_any_nequal or ir_binop_all_equal to apply to at most a vector
(with matrices broken down by the lowering pass). Break them down to
a bunch of ORed or ANDed any_nequals/all_equals.

Fixes:
glsl-array-compare
glsl-array-compare-02
glsl-fs-struct-equal
glsl-fs-struct-notequal
Bug #31909
st_to_hir.cpp
6b937465d4aeab72fabcfe5250d477cf6790a521 03-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Add a helper constructor for expressions that works out result type.

This doesn't cover all expressions or all operand types, but it will
complain if you overreach and it allows for much greater slack on the
programmer's part.
r.cpp
r.h
001eee52d461233b1e1d6ed3577965e9bcb209e8 05-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Make the symbol table's add_variable just use the variable's name.
st_to_hir.cpp
lsl_symbol_table.cpp
lsl_symbol_table.h
r_reader.cpp
r_variable.cpp
ink_functions.cpp
inker.cpp
e8f5ebf313da3ce33ccbbcf9b72946853035fbdd 05-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Make the symbol table's add_function just use the function's name.
st_to_hir.cpp
lsl_symbol_table.cpp
lsl_symbol_table.h
r_import_prototypes.cpp
r_reader.cpp
inker.cpp
1eb7a81f2e43842acd59929ce65db2142b69134d 25-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add a virtual as_discard() method.

NOTE: This is candidate for the 7.9 branch.
r.h
a82592de9219e7d8c344275066ec5870a1c0ba45 25-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Use do_common_optimization in the standalone compiler.

NOTE: This is a candidate for the 7.9 branch.
ain.cpp
e8a24c65bc06a2a098c05728df0da1e5ed61b1de 25-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't inline function prototypes.

Currently, the standalone compiler tries to do function inlining before
linking shaders (including linking against the built-in functions).
This resulted in the built-in function _prototypes_ being inlined rather
than the actual function definition.

This is only known to fix a bug in the standalone compiler; most
programs should be unaffected. Still, it seems like a good idea.

NOTE: This is a candidate for the 7.9 branch.
r_function_can_inline.cpp
02939d643f878ce3a3dcd2e7b2c6f035c64ecda7 19-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Add a helper function for determining if an rvalue could be a saturate.

Hardware pretty commonly has saturate modifiers on instructions, and
this can be used in codegen to produce those, without everyone else
needing to understand clamping other than min and max.
r.cpp
r.h
a172368ef1500fd2c7c1e55133e8e098b73d97a5 20-Nov-2010 Vinson Lee <vlee@vmware.com> glsl: Fix type of label 'default' in switch statement.
ower_vector.cpp
7aebe181f3eea51ae76f7abe200df239c7dd948a 20-Nov-2010 Vinson Lee <vlee@vmware.com> glsl: Add lower_vector.cpp to SConscript.
Conscript
bb756bb0a6935b7e0d8fd2f9d61c0437fef7d770 20-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix matrix constructors with vector parameters

When the semantics of write masks in assignments were changed, this
code was not correctly updated.

Fixes piglit test glsl-mat-from-vec-ctor-01.
st_function.cpp
63684a9ae7a66f68df1f2c68cd9358e5622122a3 19-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Combine many instruction lowering passes into one.

This should save on the overhead of tree-walking and provide a
convenient place to add more instruction lowering in the future.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
akefile
Conscript
lsl_parser_extras.cpp
r_optimization.h
ower_div_to_mul_rcp.cpp
ower_explog_to_explog2.cpp
ower_instructions.cpp
ower_mod_to_fract.cpp
ower_sub_to_add_neg.cpp
b943fb94bf50f20b773dc63558feb6b9480b8a28 19-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Simplify a type check by using type->is_integer().
ower_div_to_mul_rcp.cpp
11d6f1c69871d0b7edc28f639256460839fccd2d 16-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> 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.
akefile
r.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_optimization.h
r_validate.cpp
ower_vector.cpp
pt_algebraic.cpp
13f57d42b6929f50d8ef8b4123f46a61c46fde7b 09-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Add unary ir_expression constructor
r.cpp
r.h
8e498050dc1a1285c2218fdf4ea506c1cdcd9dd8 16-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Add ir_rvalue::is_negative_one predicate
r.cpp
r.h
fc92e87b9757eda01caf0bb3e2c31b1dbbd73aa0 11-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Eliminate assumptions about size of ir_expression::operands

This may grow in the near future.
r_clone.cpp
r_constant_expression.cpp
r_print_visitor.cpp
ower_mat_op_to_vec.cpp
pt_algebraic.cpp
f2616e56de8a48360cae8f269727b58490555f4d 18-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> 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.
r.cpp
r.h
r_constant_expression.cpp
r_validate.cpp
ad87f2ddc7e6b95e3dd5bbe4d2b19703d305c74e 19-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Make is_zero and is_one virtual methods of ir_rvalue

This eliminates the need in some cames to validate that an rvalue is
an ir_constant before checking to see if it's 0 or 1.
r.cpp
r.h
855c66bde7e51c3486e4c6abc7096a1a949a98e1 18-Nov-2010 Vinson Lee <vlee@vmware.com> glsl: Fix 'control reaches end of non-void function' warning.

Fix this GCC warning.
ir.cpp: In static member function
'static unsigned int ir_expression::get_num_operands(ir_expression_operation)':
ir.cpp:199: warning: control reaches end of non-void function
r.cpp
7819435f2ef484696560547fbc1325cb97c7174b 18-Nov-2010 Chad Versace <chad.versace@intel.com> glsl: Improve usage message for glsl_compiler

The new usage message lists possible command line options. (Newcomers to Mesa
currently have to trawl through the source to find the command line options,
and we should save them from that trouble.)

Example Output
--------------
usage: ./glsl_compiler [options] <file.vert | file.geom | file.frag>

Possible options are:
--glsl-es
--dump-ast
--dump-hir
--dump-lir
--link
ain.cpp
007f4881503b69055d65cfb20bd237673779786b 18-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refactor get_num_operands.

This adds sentinel values to the ir_expression_operation enum type:
ir_last_unop, ir_last_binop, and ir_last_opcode. They are set to the
previous one so they don't trigger "unhandled case in switch statement"
warnings, but should never be handled directly.

This allows us to remove the huge array of 1s and 2s in
ir_expression::get_num_operands().
r.cpp
r.h
9935fe705df44bb633039ca74332cc0c126ccc30 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove the ir_binop_cross opcode.
r.cpp
r.h
r_constant_expression.cpp
r_validate.cpp
af1cba2260c3546ba89d47c9612d66f513e69842 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
671ccf593e1079d0f3e1adf42831d09da91a2b68 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Reimplement the "cross" built-in without ir_binop_cross.

We are not aware of any GPU that actually implements the cross product
as a single instruction. Hence, there's no need for it to be an opcode.
Future commits will remove it entirely.
uiltins/ir/cross
302fe4049c1f409655eb283e20f9ab6397ac3db4 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> Regenerate glcpp parser.
lcpp/glcpp-parse.c
d719bf8fb4b8f511fbb00dd990fb644efc510c0e 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.

This is really supposed to be defined only if the driver supports highp
in the fragment shader - but all of our current ES2 implementations do.
So, just define it. In the future, we'll need to add a flag to
gl_context and only define the macro if the flag is set.

"Fixes" freedesktop.org bug #31673.
lcpp/glcpp-parse.y
df883eb1575a740bf91e01cbe2eaa4dbc1f9f154 17-Nov-2010 Chad Versace <chad.versace@intel.com> glsl: Fix Doxygen tag \file in recently renamed files
ower_div_to_mul_rcp.cpp
ower_explog_to_explog2.cpp
ower_if_to_cond_assign.cpp
ower_jumps.cpp
ower_mat_op_to_vec.cpp
ower_mod_to_fract.cpp
ower_sub_to_add_neg.cpp
ower_vec_index_to_cond_assign.cpp
ower_vec_index_to_swizzle.cpp
pt_algebraic.cpp
pt_constant_folding.cpp
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_copy_propagation.cpp
pt_dead_code.cpp
pt_dead_code_local.cpp
pt_dead_functions.cpp
pt_function_inlining.cpp
pt_if_simplification.cpp
pt_noop_swizzle.cpp
pt_structure_splitting.cpp
pt_swizzle_swizzle.cpp
pt_tree_grafting.cpp
b4cdba687c098eea2ecc61349a4ea02a8769909e 17-Nov-2010 Chad Versace <chad.versace@intel.com> glsl: Fix erroneous cast in ast_jump_statement::hir()

Return values were erroneously cast from (ir_rvalue*) to (ir_expression*).

NOTE: This is a candidate for the 7.9 branch.
st_to_hir.cpp
e16c9d5d03a4606b37cbeb84358925913086d6eb 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> 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.
r_constant_expression.cpp
bee901a1cf5f06a56c59189077d7f8c02a3af0d1 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated glcpp parser.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
3fb83038a05bfcbc41e649b0b6c1a2c6ff41124c 17-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version >= 1.30.

Per section 4.5.4 of the GLSL 1.30 specification.
lcpp/glcpp-parse.y
2d2d6a80c14612de683001d24cbbbb9a8f620dd5 15-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Simplify generation of swizzle for vector constructors
st_function.cpp
38e55153af031e48125b1cd0a5d939bb92379ddc 12-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Refactor is_vec_{zero,one} to be methods of ir_constant

These predicates will be used in other places soon.
r.cpp
r.h
pt_algebraic.cpp
1935bdca44ec1f0a980b6b0c024ff2e4c7032dfe 16-Nov-2010 Vinson Lee <vlee@vmware.com> glsl: Add ir_constant_expression.cpp to SConscript.

This was accidentally removed in commit 32aaf89823de11e98cb59d5ec78c66cd3e74bcd4.

Fixes SCons builds.
Conscript
9b4b70e7e28e5371ca5fddd6f8c7e09d8efd5ce0 16-Nov-2010 Brian Paul <brianp@vmware.com> glsl: remove opt_constant_expression.cpp from SConscript

And alphabetize the opt_* files.
Conscript
88f482a8391b17587fa2af07f6f40dc1f7394fa7 16-Nov-2010 Brian Paul <brianp@vmware.com> glsl: fix assorted MSVC warnings
r_constant_expression.cpp
32aaf89823de11e98cb59d5ec78c66cd3e74bcd4 15-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Rename various ir_* files to lower_* and opt_*.

This helps distinguish between lowering passes, optimization passes, and
other compiler code.
akefile
Conscript
r_algebraic.cpp
r_constant_folding.cpp
r_constant_propagation.cpp
r_constant_variable.cpp
r_copy_propagation.cpp
r_dead_code.cpp
r_dead_code_local.cpp
r_dead_functions.cpp
r_div_to_mul_rcp.cpp
r_explog_to_explog2.cpp
r_function_inlining.cpp
r_if_simplification.cpp
r_if_to_cond_assign.cpp
r_lower_jumps.cpp
r_mat_op_to_vec.cpp
r_mod_to_fract.cpp
r_noop_swizzle.cpp
r_structure_splitting.cpp
r_sub_to_add_neg.cpp
r_swizzle_swizzle.cpp
r_tree_grafting.cpp
r_vec_index_to_cond_assign.cpp
r_vec_index_to_swizzle.cpp
ower_div_to_mul_rcp.cpp
ower_explog_to_explog2.cpp
ower_if_to_cond_assign.cpp
ower_jumps.cpp
ower_mat_op_to_vec.cpp
ower_mod_to_fract.cpp
ower_sub_to_add_neg.cpp
ower_vec_index_to_cond_assign.cpp
ower_vec_index_to_swizzle.cpp
pt_algebraic.cpp
pt_constant_folding.cpp
pt_constant_propagation.cpp
pt_constant_variable.cpp
pt_copy_propagation.cpp
pt_dead_code.cpp
pt_dead_code_local.cpp
pt_dead_functions.cpp
pt_function_inlining.cpp
pt_if_simplification.cpp
pt_noop_swizzle.cpp
pt_structure_splitting.cpp
pt_swizzle_swizzle.cpp
pt_tree_grafting.cpp
46b80d6469815aa7e9956018a112ef8a19dc44c3 15-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused and out of date Makefile.am.

This was from when glsl2 lived in a separate repository and used
automake.
akefile.am
3108095198d86b31566285160a3a1a206f22c8dd 15-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add constant expression handling for asinh, acosh, and atanh.
r_constant_expression.cpp
91181c7dd48e57334e821b487a15f28ec92404cf 15-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
db9b8c062fe8ebb7321a24207f2887a28b31a55d 15-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Implement the asinh, acosh, and atanh built-in functions.
uiltins/ir/acosh
uiltins/ir/asinh
uiltins/ir/atanh
uiltins/profiles/130.frag
uiltins/profiles/130.vert
096d36872ff531b0295109165cb90ea63be7a1b1 15-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> generate_builtins.py: Fix inconsistent use of tabs and spaces warning.
uiltins/tools/generate_builtins.py
0d082c0e064e69972a302847256f3f16a3736977 14-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh autogenerated lexer and parser files.

For the last three commits.
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
7279feeb19485a62ebf820858a549c87891935c7 14-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add support for the 'u' and 'U' unsigned integer suffixes.
lsl_lexer.lpp
2b6c1a0b7cf60040ace0294ee0111de01187837a 14-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add new keywords and reserved words for GLSL 1.30.
lsl_lexer.lpp
lsl_parser.ypp
285036fbb03d7f10a8b93774d0290a33ea2e5e13 14-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Rework reserved word/keyword handling in the lexer.

This consolidates the TOKEN_OR_IDENTIFIER and RESERVED_WORD macros into
a single KEYWORD macro.

The old TOKEN_OR_IDENTIFIER macros handled the case of a word going from
an identifier to a keyword; the RESERVED_WORD macro handled a word going
from a reserved word to a language keyword. However, neither could
properly handle samplerBuffer (for example), which is an identifier in
1.10 and 1.20, a reserved word in 1.30, and a keyword in 1.40 and on.

Furthermore, the existing macros didn't properly handle reserved words
in GLSL ES 1.00. The best they could do was return a token (rather than
an identifier), resulting in an obtuse parser error, rather than a
user-friendly "you used a reserved word" error message.
lsl_lexer.lpp
5dc74e9c77de7d30ac08c25f224ffa93006d8d7c 11-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Convert glsl_type::base_type from #define'd constants to an enum.

This is nice because printing type->base_type in GDB will now give you a
readable name instead of a number.
lsl_types.cpp
lsl_types.h
ee36f14fa54723f2da3cf6054f822ebf05cca247 11-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove GLSL_TYPE_FUNCTION define.

Functions are not first class objects in GLSL, so there is never a value
of function type. No code actually used this except for one function
which asserted it shouldn't occur. One comment mentioned it, but was
incorrect. So we may as well remove it entirely.
lsl_types.h
r_function.cpp
6929cdd14bf90d5b145039265f2d43ded52020a3 08-Nov-2010 Eric Anholt <eric@anholt.net> glsl: Free the loop state context when we free the loop state.

Since this was talloced off of NULL instead of the compile state, it
was a real leak over the course of the program. Noticed with
valgrind --leak-check=full --show-reachable=yes. We should really
change these passes to generally get the compile context as an argument
so simple mistakes like this stop mattering.
oop_analysis.cpp
d67df5dd9db1cede92f1b177c890f83809bb4582 29-Sep-2010 Aras Pranckevicius <aras@unity3d.com> glsl: fix crash in loop analysis when some controls can't be determined

Fixes loop-07.frag.
oop_controls.cpp
afb6fb9a92afaecbb0f8e9e65380c842667a4bd4 10-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unnecessary "unused variable" warning suppression.

The "instructions" variable -is- used, so the cast to void can go away.
st_function.cpp
956ae44dcf63671bb5707c369d3ff2bee3476cd9 09-Nov-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Fix incorrect gl_type of sampler2DArray and sampler1DArrayShadow

NOTE: this is a candidate for the 7.9 branch.
uiltin_types.h
b62c1c4595551c4936323135224a5ea686ba972a 09-Nov-2010 Chad Versace <chad.versace@intel.com> glsl: Fix ir_expression::constant_expression_value()

When the type of the ir_expression is error_type, return NULL.
This fixes bug 31371.
r_constant_expression.cpp
a457ca7844c7943e17aa18a73757cc4ac965e200 09-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> ir_dead_functions: Actually free dead functions and signatures.

This makes linked shaders use around 36k less memory since the
built-in prototypes are now freed.
r_dead_functions.cpp
46c19700676e17bfaa0a88346d512449fbeede79 03-Nov-2010 Benjamin Franzke <benjaminfranzke@googlemail.com> r600g: implement texture_get_handle (needed for eglExportDRMImageMESA)
lcpp/glcpp-lex.c
lsl_parser.cpp
lsl_parser.h
c180e95d267c302c40e1cb92e5b134b4e370ef2e 03-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Fix some potential NULL pointer dereferences.

Found by inspection.
r_reader.cpp
e751ce39bfbc5be35005cedcd3d98cf820f68cde 03-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Remove useless error check.

It's already been determined that length == 3, so clearly swiz->next is
a valid S-Expression.
r_reader.cpp
0fd665ca63ba37b9a3022f21a8d9f363530e2038 31-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Return a specific ir_dereference variant.

There's really no reason to return the base class when we have more
specific information about what type it is.
r_reader.cpp
d2c23ac82a4038c0f69b6ce5b0c49f763a65df8a 31-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't print a useless space at the end of an S-Expression list.

We really only want to print spaces -between- elements, not after each
element. This cleans up error messages from IR reader, making them
(mildly) easier to read.
_expression.cpp
6c4a83ca3ea9e51dd268be132fbc589f066cf257 03-Nov-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
91b72864b0b774a25712cf7e5196a22acc1693d9 31-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Clean up some ugly autogenerated code in atan.

In particular, calling the abs function is silly, since there's already
an expression opcode for that. Also, assigning to temporaries then
assigning those to the final location is rather redundant.
uiltins/ir/atan
84566c770a8742638ff11fbae59756a50513d621 31-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Rename 'x' to 'y_over_x' in atan(float) implementation.

For consistency with the vec2/vec3/vec4 variants.
uiltins/ir/atan
cff1aeea10c6d8520cbb17381d81a684b2e9408b 29-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove unused ARRAY_SIZE macro.

It's also equivalent to Elements(...) which is already used elsewhere.
r.h
3acc8265200295265b476222299a013791050b73 25-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> Fix build on systems where "python" is python 3.

First, it changes autoconf to use a "python2" binary when available,
rather than plain "python" (which is ambiguous). Secondly, it changes
the Makefiles to use $(PYTHON) $(PYTHON_FLAGS) rather than calling
python directly.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Matthew William Cox <matt@mattcox.ca>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
akefile
ba2382f50d7815947e17fe993b39feb573638d12 25-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix constant component count in vector constructor emitting.

Fixes freedesktop.org bug #31101 as well as piglit test cases
assignment-type-mismatch.vert and constructor-28.vert.
st_function.cpp
6e006273840282e06a08655553821ef8176b2d9c 23-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Fix ast-to-hir for ARB_fragment_coord_conventions

Function ast_declarator_list::hir(), when processing keywords added by
extension ARB_fragment_coord_conventions, made the mistake of checking only if
the extension was __supported by the driver__. The correct behavior is to check
if the extensi0n is __enabled in the parse state__.

NOTE: this is a candidate for the 7.9 branch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
3f5fde5c45db88caa228c9d169648f04660c6531 21-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated file builtin_function.cpp.

Since this is just generated by python, it's questionable whether this
should continue to live in the repository - Mesa already has other
things generated from python as part of the build process.
uiltin_function.cpp
2cacaf6e7b9bc38efd47413b5e667b6e750698b8 21-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> generate_builtins.py: Output large strings as arrays of characters.

This works around MSVC's 65535 byte limit, unfortunately at the expense
of any semblance of readability and much larger file size. Hopefully I
can implement a better solution later, but for now this fixes the build.
uiltins/tools/generate_builtins.py
cc04347b8ddf5802a72892d657720890337d48b1 19-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
574c53f551cb35173aee4acfa5c374613b953264 19-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add support for GLSL 1.30's modf built-in.
uiltins/ir/modf
uiltins/profiles/130.frag
uiltins/profiles/130.vert
94a36faed7ae0c795665b6cfb4dd4324ffaa5fa8 21-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Refresh autogenerated lexer file.
lcpp/glcpp-lex.c
bd55ba568b301d0f764cd1ca015e84e1ae932c8b 21-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Return NEWLINE token for newlines inside multi-line comments.

This is necessary for the main compiler to get correct line numbers.
lcpp/glcpp-lex.l
a75da2c0e85eb6b8279ec895c3f74cc4aefc0257 20-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove useless ir_shader enumeration value.
st_to_hir.cpp
lsl_parser_extras.cpp
lsl_parser_extras.h
r_variable.cpp
460da0db4add19b79050b816e3bef086293ab630 20-Oct-2010 Vinson Lee <vlee@vmware.com> glsl: Add assert for unhandled ir_shader case.

Silences this GCC warning.
ast_to_hir.cpp: In function 'void apply_type_qualifier_to_variable(const
ast_type_qualifier*, ir_variable*, _mesa_glsl_parse_state*, YYLTYPE*)'
ast_to_hir.cpp:1768: warning: enumeration value 'ir_shader' not handled
in switch
st_to_hir.cpp
cc90e62d70d91fb16abcd66c61c211c0fd573339 20-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Improve handling of unread/unwritten shader inputs/outputs

Previously some shader input or outputs that hadn't received location
assignments could slip through. This could happen when a shader
contained user-defined varyings and was used with either
fixed-function or assembly shaders.

See the piglit tests glsl-[fv]s-user-varying-ff and
sso-user-varying-0[12].

NOTE: this is a candidate for the 7.9 branch.
inker.cpp
974fb466f299fc569a86097936ab89c8c369f6d2 15-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Commit generated file glsl_lexer.cpp

Changes are due to commit "glsl: Fix lexer rule for ^=".
lsl_lexer.cpp
cba9062d584c2359ce3cd5e0e9c57e5d6b67509e 15-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Fix lexer rule for ^=

The caret is a special character, and needs to be quoted or escaped.
lsl_lexer.lpp
d03ac0f8d81fd3032d271586d936f14b7d9201d5 15-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Implement ast-to-hir for bit-logic ops

Implement by adding to ast_expression::hir() the following cases:
- ast_and_assign
- ast_or_assign
- ast_xor_assign
st_to_hir.cpp
cfdbf8bc8497b29fbdd9fa7bd00da554aecb5962 15-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Define bit_logic_result_type() in ast_to_hir.cpp

This function type checks the operands of and returns the result type of
bit-logic operations. It replaces the type checking performed in the
following cases of ast_expression::hir() :
- ast_bit_and
- ast_bit_or
- ast_bit_xor
st_to_hir.cpp
338ed6ec297d76746b6466c26c307722af965e60 15-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Implement ast-to-hir for bit-shift-assignment

Implement by adding to ast_expression::hir() these cases:
- ast_ls_assign
- ast_rs_assign
st_to_hir.cpp
c0197ab0af94ed0f3b2d453fb1ee6589f15d8e9c 15-Oct-2010 Chad Versace <chad.versace@intel.com> glsl: Define shift_result_type() in ast_to_hir.cpp

This function type checks the operands of and returns the result type of
bit-shift operations. It replaces the type checking performed in the following
cases of ast_expression::hir() :
- ast_lshift
- ast_rshift
st_to_hir.cpp
9c80fa824cedd6e267a92d3ae9e092a316d78aa9 19-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Regenerate parser files.
lsl_parser.cpp
lsl_parser.h
0eb0b44647ec9218f5c6ce90e3f50273d6f25c90 19-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix copy and paste error in ast_bit_and node creation.

All & operations were incorrectly being generated as ast_bit_or.
lsl_parser.ypp
b8276e46f593fd9d938258636a2ba4452d895338 18-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't return NULL IR for erroneous bit-shift operators.

Existing code relies on IR being generated (possibly with error type)
rather than returning NULL. So, don't break - go ahead and generate the
operation. As long as an error is flagged, things will work out.

Fixes fd.o bug #30914.
st_to_hir.cpp
b2578ef873c4c9dd831a23501a677bf523de90fc 15-Oct-2010 Brian Paul <brianp@vmware.com> glsl: add ir_unop_round_even case to silence unhandled enum warning
r_validate.cpp
f29ff6efa6db63c9b554076a2ec6addcba1f737e 15-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Trivial indention fix
inker.cpp
e2c1fe3eb0fa47f5501b4ec8cd6b732db7ca84be 13-Oct-2010 Chad Versace <chad@chad-versace.us> 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.
r_validate.cpp
4761d0d22ba79fa34adf679007498287e9fedca2 10-Oct-2010 Chad Versace <chad@chad-versace.us> 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
r_constant_expression.cpp
adea8150a70f975c31c68f3e84ec3f8b0b448cf0 10-Oct-2010 Chad Versace <chad@chad-versace.us> 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
r_constant_expression.cpp
90a8b792c04679fc745e5a68ead9f7c37b8d07c4 09-Oct-2010 Chad Versace <chad@chad-versace.us> glsl: Implement constant expr evaluation for bitwise-not

Implement by adding a case to ir_expression::constant_expression_value()
for ir_unop_bit_not.
r_constant_expression.cpp
5c4c36f7f3842e287b303b1eca8d260c37e3580b 09-Oct-2010 Chad Versace <chad@chad-versace.us> 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
st_to_hir.cpp
r_validate.cpp
f88b4eaa8f6659fd1dab72697b8e80e157bee17f 09-Oct-2010 Chad Versace <chad@chad-versace.us> glsl: Change generated file glsl_lexer.cpp
lsl_lexer.cpp
7abdc71afa7e9425badb2d07453c59fa3c20f5f1 09-Oct-2010 Chad Versace <chad@chad-versace.us> glsl: Add lexer rules for << and >> in GLSL 1.30

Commit for generated file glsl_lexer.cpp follows this commit.
lsl_lexer.lpp
3322fbaf3b5e305ce00c1d08c26965bb98e0cef0 14-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Slightly change the semantic of _LinkedShaders

Previously _LinkedShaders was a compact array of the linked shaders
for each shader stage. Now it is arranged such that each slot,
indexed by the MESA_SHADER_* defines, refers to a specific shader
stage. As a result, some slots will be NULL. This makes things a
little more complex in the linker, but it simplifies things in other
places.

As a side effect _NumLinkedShaders is removed.

NOTE: This may be a candidate for the 7.9 branch. If there are other
patches that get backported to 7.9 that use _LinkedShader, this patch
should be cherry picked also.
lcpp/glcpp.c
inker.cpp
ain.cpp
2bc704d5432b8f0e0a0dc3c947ebf0a9839601b9 14-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
27ced5c5ff907557007ed6cb78cef5810cf48ef5 14-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add support for the 1.30 round() built-in.

This implements round() via the ir_unop_round_even opcode, rather than
adding a new opcode. We may wish to add one in the future, since it
might enable a small performance increase on some hardware, but for now,
this should suffice.
uiltins/ir/round
uiltins/profiles/130.frag
uiltins/profiles/130.vert
6dc204c5dc723bbf9337aa7787cd6cc309a24285 14-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add front-end support for GLSL 1.30's roundEven built-in.

Implemented using the op-code introduced in the previous commit.
uiltins/ir/roundEven
uiltins/profiles/130.frag
uiltins/profiles/130.vert
d85d25dd1f4fd281bd210ba6ba5135ba1e3b535f 14-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add a new ir_unop_round_even opcode for GLSL 1.30's roundEven.

Also, update ir_to_mesa's "1.30 is unsupported" case to "handle" it.
r.cpp
r.h
f9bd4c6c26e406834aaeec85d9068a901a4defb0 14-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
090dd4fcc5d9f905c9dee9a8ad9972dad9d1166a 14-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add front-end support for the "trunc" built-in.
uiltins/ir/trunc
uiltins/profiles/130.frag
uiltins/profiles/130.vert
4a45595cf3d6a238bb4d528d30139392618b39df 14-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Reject shaders that have unresolved function calls

This really amounts to just using the return value from
link_function_calls. All the work was being done, but the result was
being ignored.

Fixes piglit test link-unresolved-funciton.

NOTE: this is a candidate for the 7.9 branch.
inker.cpp
720bdfbceb5b20bbbb4090cca7a1825ca5f89260 13-Oct-2010 Vinson Lee <vlee@vmware.com> 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.
r_constant_expression.cpp
f9995b30756140724f41daf963fa06167912be7f 12-Oct-2010 Kristian Høgsberg <krh@bitplanet.net> Drop GLcontext typedef and use struct gl_context instead
uiltin_function.cpp
uiltins/tools/generate_builtins.py
lsl_parser_extras.cpp
lsl_parser_extras.h
inker.cpp
ain.cpp
rogram.h
d9671863eaae41ba28b6fe82e3e7d1dac12f514c 06-Oct-2010 Dave Airlie <airlied@redhat.com> glsl: add support for shader stencil export

This adds proper support for the GL_ARB_shader_stencil_export extension
to the GLSL compiler. Thanks to Ian for pointing out where I need to add things.
lsl_parser_extras.cpp
lsl_parser_extras.h
r_variable.cpp
3633e1f538e42ac04700aa98b48e3157b3406c14 12-Oct-2010 Brian Paul <brianp@vmware.com> glsl2: fix signed/unsigned comparison warning
oop_unroll.cpp
41c2079855cde03470d811a637e9abf1b5a3763f 08-Oct-2010 Chad Versace <chad@chad-versace.us> glsl: Changes in generated file glsl_lexer.cpp

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_lexer.cpp
0c9fef6111162498035e05241e492fe1bb0df6a4 08-Oct-2010 Chad Versace <chad@chad-versace.us> glsl: Add lexer rules for uint and uvecN (N=2..4)

Commit for generated file glsl_lexer.cpp follows this commit.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_lexer.lpp
fc99a3beb92326caacbbb231d2f2090bee48b1f7 08-Oct-2010 Chad Versace <chad@chad-versace.us> glsl: Add glsl_type::uvecN_type for N=2,3

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
uiltin_types.h
lsl_types.h
0ea8b993324365769ed0aa2f7bab2dd9281b4924 08-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Remove const decoration from inlined function parameters

The constness of the function parameter gets inlined with the rest of
the function. However, there is also an assignment to the parameter.
If this occurs inside a loop the loop analysis code will get confused
by the assignment to a read-only variable.

Fixes bugzilla #30552.

NOTE: this is a candidate for the 7.9 branch.
r_function_inlining.cpp
68a4fc9d5a9dd3b61472451d659275531253b67d 08-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Add linker support for explicit attribute locations
st_to_hir.cpp
r_variable.cpp
inker.cpp
eee68d3631813580a14fa51fda6f0c959279256c 08-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Track explicit location in AST to IR translation
st_to_hir.cpp
r.cpp
r.h
r_clone.cpp
2b45ba8bce6a2919762a2def3095c7b9ba05d692 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Regenerate files changes by previous commit
lsl_lexer.cpp
lsl_parser.cpp
7f68cbdc4d9f602dc2619ac4a90283a4f057a8cb 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Add parser support for GL_ARB_explicit_attrib_location layouts

Only layout(location=#) is supported. Setting the index requires GLSL
1.30 and GL_ARB_blend_func_extended.
st.h
lsl_lexer.lpp
lsl_parser.ypp
lsl_parser_extras.cpp
lsl_parser_extras.h
eafebed5bdfd853c6ec7f7275e219378e441c49c 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glcpp: Regenerate files changes by previous commit
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
e0c9f67be5c47273416a50e011f70aa9e2021a65 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glcpp: Add the define for ARB_explicit_attrib_location when present
lcpp/glcpp-parse.y
5ed6610d11cb3a28420e11adb072131fb9dcdfdb 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Regenerate files modified by previous commits
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
e24d35a5b59ca1e75b69a32db6294787378a963f 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Wrap ast_type_qualifier contents in a struct in a union

This will ease adding non-bit fields in the near future.
st.h
st_to_hir.cpp
st_type.cpp
lsl_parser.ypp
lsl_parser_extras.cpp
5ff4cfb788291ef7c8d6412d65aee708b41bac86 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Clear type_qualifier using memset
lsl_parser.ypp
fd2aa7d313b2546dc25f9f7810a0b3767ee679f9 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Slight refactor of error / warning checking for ARB_fcc layout
lsl_parser.ypp
dd93035a4df9daaad8cb47f2cc412d5dd3a9e3c8 06-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Refactor 'layout' grammar to match GLSL 1.60 spec grammar
lsl_parser.ypp
4b5489dd6f6d21c9d2e3f3d6d6467dcd429264a2 08-Oct-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Fail linking if assign_attribute_locations fails
inker.cpp
841503fddf647bf7eaa715f3500c36389bca2c80 02-Oct-2010 Vinson Lee <vlee@vmware.com> glsl: Remove unnecessary header.
ower_texture_projection.cpp
aae338104fa6022b8b1d6b22c7ad1115b252b9b6 01-Oct-2010 Eric Anholt <eric@anholt.net> glsl: Add a lowering pass for texture projection.
akefile
r_optimization.h
ower_texture_projection.cpp
565ff676887fc40b4715b44d9407c638480485e6 29-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: "Copyright", not "Constantright"

Clearly this started out as ir_copy_propagation.cpp, but the search and
replace was a bit overzealous.
r_constant_propagation.cpp
586b4b500fed64fb724beb3753bc190cd1c676e0 28-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Also update implicit sizes of varyings at link time.

Otherwise, we'll often end up with gl_TexCoord being 0 length, for
example. With ir_to_mesa, things ended up working out anyway, as long
as multiple implicitly-sized arrays weren't involved.
inker.cpp
5e8ed7a79b381d559b059987bd99c68d40f641ca 28-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Add validation that a swizzle only references valid channels.

Caught the bug in the previous commit.
r_validate.cpp
668cdbe12958247f4a563c362dbf3247de7ccc3f 28-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Fix broadcast_index of lower_variable_index_to_cond_assign.

It's trying to get an int smeared across all channels, not trying to
get a 1:1 mapping of a subset of a vector's channels. This usually
ended up not mattering with ir_to_mesa, since it just smears floats
into every chan of a vec4.

Fixes:
glsl1-temp array with swizzled variable indexing
ower_variable_index_to_cond_assign.cpp
3ffab367685c0e0c7ce4d01a3b9b934cb0b15883 22-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Fix copy'n'wasted ir_noop_swizzle conditions.

It considered .xyyy a noop for vec4 instead of .xyzw, and similar for vec3.
r_noop_swizzle.cpp
b39e6f33b60ef9bbaf81f320aaca6a440d8a6a8f 22-Sep-2010 Eric Anholt <eric@anholt.net> 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>
st_function.cpp
uiltin_function.cpp
uiltins/ir/noise2
uiltins/ir/noise3
uiltins/ir/noise4
r.cpp
r.h
r_constant_propagation.cpp
r_mat_op_to_vec.cpp
r_validate.cpp
2b95525429935474ee4b507348507da45adc6872 21-Sep-2010 Brian Paul <brianp@vmware.com> glsl2: fix typo in error msg
inker.cpp
b5bb21562942dab7571ef748c3ca562a66f25b33 21-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Add definition of gl_TextureMatrix inverse/transpose builtins.

Fixes glsl2/builtin-texturematrix.
Bug #30196.
r_variable.cpp
6ea16b6c510ee7f0e68505838a99562f0852f8e4 19-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> 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.
r_constant_expression.cpp
14eea268284491d64ff92b37723bff1e9ff14b40 19-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add comments to clarify the types of comparison binops.
r.h
17391241599137b9729e9ee6c5487d05e04d8aee 20-Sep-2010 Brian Paul <brianp@vmware.com> 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*’"
r_validate.cpp
e053d62aa573651abdd78666d299272c8219a3aa 18-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Add doxygen comments
st.h
r.h
dbd24805071332a06828bd92ed0f6e49c897c146 18-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Switch comparison functions to just return an expression.
uiltin_function.cpp
uiltins/ir/greaterThan
uiltins/ir/greaterThanEqual
uiltins/ir/lessThan
uiltins/ir/lessThanEqual
52f9156e88d87a528996f01795203feba3f789f1 18-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Fix equal and notEqual builtins.

Commit 309cd4115b7cba669a0bf858e7809cb6dae90ddf incorrectly converted
these to all_equal and any_nequal, which is the wrong operation.
uiltin_function.cpp
uiltins/ir/equal
uiltins/ir/notEqual
ca92ae2699c4aad21c0811b9a5562b9223816caf 18-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Properly handle nested structure types.

Fixes piglit test CorrectFull.frag.
st_to_hir.cpp
lsl_parser_extras.cpp
3894fddccc3a6da91513b49142a8f0dbbf8aa448 18-Sep-2010 Tilman Sauerbeck <tilman@code-monkey.de> glsl2: Fixed cloning of ir_call error instructions.

Those have the callee field set to the null pointer, so
calling the public constructor will segfault.

Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
r_clone.cpp
a822ae3f1a14ddd00a6368d767213ea42d00e7fb 18-Sep-2010 Vinson Lee <vlee@vmware.com> glsl: Fix 'control reaches end of non-void function' warning.

Fixes this GCC warning.

lower_variable_index_to_cond_assign.cpp:
In member function
'bool variable_index_to_cond_assign_visitor::needs_lowering(ir_dereference_array*) const':

lower_variable_index_to_cond_assign.cpp:261:
warning: control reaches end of non-void function
ower_variable_index_to_cond_assign.cpp
19f8f32a967fbe376ca0aae9be12100f4cdf9d31 17-Sep-2010 Tilman Sauerbeck <tilman@code-monkey.de> glsl2: Empty functions can be inlined.

Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
r_function_can_inline.cpp
a6ecd1c3724a78b76ab9e81ea39632f1279021f8 16-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add flags to enable variable index lowering
r_optimization.h
ower_variable_index_to_cond_assign.cpp
6e4fe39da26bf101f5fe1103ba426c0903445352 16-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Refactor testing for whether a deref is of a matrix or array
ower_variable_index_to_cond_assign.cpp
a47539c7a155475de00fa812842721d239abb3f4 08-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> glsl: add pass to lower variable array indexing to conditional assignments

Currenly GLSL happily generates indirect addressing of any kind of
arrays.

Unfortunately DirectX 9 GPUs are not guaranteed to support any of them in
general.

This pass fixes that by lowering such constructs to a binary search on the
values, followed at the end by vectorized generation of equality masks, and
4 conditional assignments for each mask generation.

Note that this requires the ir_binop_equal change so that we can emit SEQ
to generate the boolean masks.

Unfortunately, ir_structure_splitting is too dumb to turn the resulting
constant array references to individual variables, so this will need to
be added too before this pass can actually be effective for temps.

Several patches in the glsl2-lower-variable-indexing were squashed
into this commit. These patches fix bugs in Luca's original
implementation, and the individual patches can be seen in that branch.
This was done to aid bisecting in the future.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
akefile
akefile.am
Conscript
r_optimization.h
ower_variable_index_to_cond_assign.cpp
8fbe968a62f845da2a1491c398acf0b2140d2372 16-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't print blank (function ...) headers for built-ins.

Fixes a regression caused when I added my GLSL ES support.
r_print_visitor.cpp
81f03393982c29f8f4165b5629c8e8fb708b97a3 16-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Change from has_builtin_signature to has_user_signature.

The print visitor needs this, and the only existing user can work with
has_user_signature just as well.
st_to_hir.cpp
r.cpp
r.h
f20f2cc3306310f6fc4c338f91cfac10f98335d3 15-Sep-2010 Vinson Lee <vlee@vmware.com> glsl: Fix 'format not a string literal and no format arguments' warning.

Fix the following GCC warning.
loop_controls.cpp: In function 'int calculate_iterations(ir_rvalue*, ir_rvalue*, ir_rvalue*, ir_expression_operation)':
loop_controls.cpp:88: warning: format not a string literal and no format arguments
oop_controls.cpp
1c0644e9dac946131594216e23953a9c85335282 14-Sep-2010 Brian Paul <brianp@vmware.com> glsl2: add case for ir_unop_noise

Silences a compiler warning. Still need to add some assertions
for this case.
r_validate.cpp
2b04ead569fbfa48ea01d2f25b20f1f8a8b8dee1 14-Sep-2010 Brian Paul <brianp@vmware.com> glsl2: fix comments
r_if_simplification.cpp
r_lower_jumps.cpp
r_mod_to_fract.cpp
309cd4115b7cba669a0bf858e7809cb6dae90ddf 14-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Port equal() and notEqual() to ir_unop_all_equal and ir_unop_any_nequal
uiltin_function.cpp
uiltins/ir/equal
uiltins/ir/notEqual
4dfb89904c0a3d2166e9a3fc0253a254680e91bc 08-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> 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>
st_to_hir.cpp
r.cpp
r.h
r_algebraic.cpp
r_constant_expression.cpp
r_mat_op_to_vec.cpp
r_validate.cpp
2cdbced10d98214616bcc5f960b21185c433d23b 07-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> loop_unroll: unroll loops with (lowered) breaks

If the loop ends with an if with one break or in a single break unroll
it. Loops that end with a continue will have that continue removed by
the redundant jump optimizer. Likewise loops that end with an
if-statement with a break at the end of both branches will have the
break pulled out after the if-statement.

Loops of the form

for (...) {
do_something1();
if (cond) {
do_something2();
break;
} else {
do_something3();
}
}

will be unrolled as

do_something1();
if (cond) {
do_something2();
} else {
do_something3();
do_something1();
if (cond) {
do_something2();
} else {
do_something3();
/* Repeat inserting iterations here.*/
}
}

ir_lower_jumps can guarantee that all loops are put in this form
and thus all loops are now potentially unrollable if an upper bound
on the number of iterations can be found.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
oop_unroll.cpp
8f2214f4892acb994d13531d555196bd8f242dad 13-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add pass to remove redundant jumps
akefile
akefile.am
Conscript
lsl_parser_extras.cpp
r_optimization.h
pt_redundant_jumps.cpp
e79a1bb02a0ce3c265c4a64c117018a9207064c9 13-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl: Explain file naming convention
EADME
710d41131b9715c5c378e0138d991f346647b9c8 07-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> loop_controls: fix analysis of already analyzed loops

The loop_controls pass didn't look at the counter values it put in ir_loop
on previous iterations, so while the first iteration worked, subsequent
ones couldn't determine max_iterations.
oop_controls.cpp
3361cbac2a883818efeb2b3e27405eeefce60f63 07-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> glsl: add continue/break/return unification/elimination pass (v2)

Changes in v2:
- Base class renamed to ir_control_flow_visitor
- Tried to comply with coding style

This is a new pass that supersedes ir_if_return and "lowers" jumps
to if/else structures.

Currently it causes no regressions on softpipe and nv40, but I'm not sure
whether the piglit glsl tests are thorough enough, so consider this
experimental.

It can be asked to:
1. Pull jumps out of ifs where possible
2. Remove all "continue"s, replacing them with an "execute flag"
3. Replace all "break" with a single conditional one at the end of the loop
4. Replace all "return"s with a single return at the end of the function,
for the main function and/or other functions

This gives several great benefits:
1. All functions can be inlined after this pass
2. nv40 and other pre-DX10 chips without "continue" can be supported
3. nv30 and other pre-DX10 chips with no control flow at all are better supported

Note that for full effect we should also teach the unroller to unroll
loops with a fixed maximum number of iterations but with the canonical
conditional "break" that this pass will insert if asked to.

Continues are lowered by adding a per-loop "execute flag", initialized to
TRUE, that when cleared inhibits all execution until the end of the loop.

Breaks are lowered to continues, plus setting a "break flag" that is checked
at the end of the loop, and trigger the unique "break".

Returns are lowered to breaks/continues, plus adding a "return flag" that
causes loops to break again out of their enclosing loops until all the
loops are exited: then the "execute flag" logic will ignore everything
until the end of the function.

Note that "continue" and "return" can also be implemented by adding
a dummy loop and using break.
However, this is bad for hardware with limited nesting depth, and
prevents further optimization, and thus is not currently performed.
akefile
Conscript
lsl_parser_extras.cpp
r_if_return.cpp
r_lower_jumps.cpp
r_optimization.h
55adbebc62a6a819a005adf48f367e7f378c7349 07-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> glsl: add ir_control_flow_visitor

This is just a subclass of ir_visitor with empty implementations of all
the visit methods for non-control flow nodes.

Used to avoid duplicating that in ir_visitor subclasses.

ir_hierarchical_visitor is another way to solve this, but is less natural
for some applications.
r_visitor.h
379e2e77badfaa367e1fb47a870a7b5dbcb6a7a6 10-Sep-2010 Jakob Bornecrantz <wallbraker@gmail.com> glsl2: Fix scons build for all platforms
Conscript
1f3c7d968c4313dbb71bc93306556cc9292d06ef 02-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Implement noise[1234] built-in functions using ir_unop_noise
uiltin_function.cpp
uiltins/ir/noise1
uiltins/ir/noise2
uiltins/ir/noise3
uiltins/ir/noise4
547131ac8750acabd030972fc768705c13d19ef7 10-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add lowering pass to remove noise opcodes
akefile
akefile.am
r_optimization.h
ower_noise.cpp
3a5ce85cfa4914711e56c8cf831699242618928e 02-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add ir_unop_noise
r.cpp
r.h
6dcca5a308efd7a85caa52f970ed020926c487e9 10-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: normalize of a negative scalar should be -1.0.
uiltin_function.cpp
uiltins/ir/normalize
e591c4625cae63660c5000fbab366e40fe154ab0 05-Sep-2010 Luca Barbieri <luca@luca-barbieri.com> glsl: add several EmitNo* options, and MaxUnrollIterations

This increases the chance that GLSL programs will actually work.

Note that continues and returns are not yet lowered, so linking
will just fail if not supported.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
lsl_parser_extras.cpp
r_optimization.h
inker.cpp
oop_analysis.h
oop_unroll.cpp
ain.cpp
5ecd9c70cecc05eaa1fef05f9bd4e8cf50f2c03a 09-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Add info about talloc and optimization passes to the README.
EADME
e04f90712d8e04ce9d2fee46d0cccf818432c7d9 09-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Update README talking about multi-instruction operations.

The previous thing taking multiple instructions ended up being handled
at the IR level, as we suggested would be the common result. Pick a
new one.
EADME
7fc882643ce1c57fb8f60d8c5edd761eff404749 09-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Set the API in the fake context.

Otherwise it gets used uninitialized.
uiltin_function.cpp
uiltins/tools/generate_builtins.py
f69a6647fbd5e7cf4406fcc877ff78b507344073 09-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Clear out profile pointers in _mesa_glsl_release_functions

Otherwise builtin_profiles contains dangling pointers the next time
_mesa_read_profile is called. I suspect this may fix bugzilla #29847,
but I was never able to reproduce it.
uiltin_function.cpp
uiltins/tools/generate_builtins.py
fc1daab2a2846912d3da5eb69e1ce0afbf08ab04 09-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix for scalar float built-in definitions.

These need abs, and we need more tests.
uiltin_function.cpp
uiltins/ir/distance
uiltins/ir/length
c3db43df046daf46e98cc3043129b5b56c513799 09-Sep-2010 Eric Anholt <eric@anholt.net> glsl: regenerate builtins
uiltin_function.cpp
aa973d3533bd98afb0c2140c30d151ec4a0fb898 09-Sep-2010 Eric Anholt <eric@anholt.net> glsl: Fix typo in builtin step() using a wrong channel.
uiltins/ir/step
368dc76f04e19f5070d1f41795ea8cde2964639f 08-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_validate: Ensure ir_binop_dot is only used on vector types.
r_validate.cpp
4b2ffa0a42ca80662f4db54c561784766d7c485a 08-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh automatically generated file builtin_function.cpp.
uiltin_function.cpp
1f7e6e1e724150e5e7309bdb781d7873bcc13687 08-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Don't use ir_binop_dot on floating point values.

ir_binop_dot is only defined for vector types. Use ir_binop_mul.
uiltins/ir/dot
uiltins/ir/faceforward
uiltins/ir/reflect
uiltins/ir/refract
84160a0454b17306e6b9bff5b6e50e54959c5680 08-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Simplify degenerate scalar float cases.

The code being generated was just stupid, considering that:
- normalize(x) = 1.0
- length(x) = x
- distance(x, y) = x - y
uiltins/ir/distance
uiltins/ir/length
uiltins/ir/normalize
961f42c9bd795204e031ea6a31a2ae04ba2e4067 08-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Make sure _mesa_glsl_parse_state constructor gets a context

Fix an major regression in dc754586. Too bad that change was
obviously never tested.
uiltin_function.cpp
uiltins/tools/generate_builtins.py
1a5b32ca0198488e7d616c8cd968471166a97ef3 08-Sep-2010 Chia-I Wu <olv@lunarg.com> glsl: Support GLSL ES in the standalone compile.

GLSL ES mode is enabled when --glsl-es is passed to glsl_compiler.
ain.cpp
dc754586ca84741b4df5b72fd235c4134816854c 08-Sep-2010 Chia-I Wu <olv@lunarg.com> glsl: Require a context in _mesa_glsl_parse_state.

Create a dummy context in the standalone compiler and pass it to
_mesa_glsl_parse_state.
lsl_parser_extras.cpp
ain.cpp
48e789d71e01b0a7185555735b4a26b1a53d0825 08-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Fix build on non-GCC compilers.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
10eaa8bcbce1cd6d2e120e913f7abafde9675215 07-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Mark arrays as lvalues in GLSL ES, but prohibit assignment.

This allows them to be passed as out/inout parameters, but still
prevents them from being used as the target of an assignment. This is
per section 5.8 of the GLSL ES 1.00 specification.
st_to_hir.cpp
a98d5a5ac8b61edc14f60836e5a997bb88fc5c80 05-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Allow overloading of built-ins without hiding in GLSL ES.

The rules are explicitly different from desktop GLSL.
st_to_hir.cpp
f412fac5b46eb274cbed8e62234d5dbfd859f1fe 05-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Move is_builtin flag back to ir_function_signature.

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.
st_to_hir.cpp
r.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_import_prototypes.cpp
r_print_visitor.cpp
r_reader.cpp
inker.cpp
c98deb18d5836f75cf62562f9304e4d90e0ea920 16-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Reject embedded structure definitions in GLSL ES 1.00.
st_to_hir.cpp
d8e34e29eb58c38ef60226156aab8f4a93b397b7 07-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Reject unsized array declarations in GLSL ES 1.00.
st_to_hir.cpp
b4ec3f268c4a81c4b9047813423bdf49f0cb1cb5 01-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Allow matrix-from-matrix constructors in GLSL ES.

Everything but 1.10 supports this, so just change the check to ==.
st_function.cpp
5a81d057dbbf9f4b8fbeee471df70603009c8d6b 31-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> linker: Fix assertion and cross-version checks for version 100.

Fixes an assert (min_version >= 110) which was no longer correct, and
also prohibits linking ES2 shaders with non-ES2 shaders. I'm not
positive this is correct, but the specification doesn't seem to say.
inker.cpp
116dc670e96f380b3982030c77d26d102109cef3 16-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add built-in function profiles for GLSL ES 1.00.
uiltin_function.cpp
uiltins/profiles/100.frag
uiltins/profiles/100.vert
b4fe4d52b6c642e2a30162c0e27f81622235d861 07-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add built-in variables for GLSL ES 1.00.
uiltin_variables.h
r_variable.cpp
76deef138ee25ab57b4716aef41ce0c94081f20a 07-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Split out types that are in 1.10 but not GLSL ES 1.00.
uiltin_types.h
lsl_types.cpp
lsl_types.h
c5e74871d9e4b555f3927fd11944c769d466bd12 05-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Recognize GLSL ES 1.00 keywords.
lsl_lexer.cpp
lsl_lexer.lpp
lsl_parser.cpp
lsl_parser.ypp
7dcfc44b72f00ba5a38cb02123c80113440f0de9 05-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.

Also define it if #version 100 is encountered.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
lcpp/glcpp-parse.y
lcpp/glcpp.c
lcpp/glcpp.h
lcpp/pp.c
lsl_parser_extras.h
ain.cpp
719caa403ecc3345b86708f8172600d80132d6cb 16-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Accept language version 100 and make it the default on ES2.
lsl_parser.cpp
lsl_parser.ypp
lsl_parser_extras.cpp
lsl_parser_extras.h
814c89abdbcd5b841b98746af921796df0362238 05-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Set default language version in mesa_glsl_parse_state constructor.

This should make it easier to change the default version based on the
API (say, version 1.00 for OpenGL ES).

Also, synchronize the symbol table's version with the parse state's
version just before doing AST-to-HIR. This way, it will be set when
it matters, but the main initialization code doesn't have to care about
the symbol table.
st_to_hir.cpp
lsl_parser.cpp
lsl_parser.ypp
lsl_parser_extras.cpp
f09fabc448c0781f0cf9160565e1b0bab59a16e5 07-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Forbid array-types in ?: operator in GLSL 1.10

Fixes bugzilla #30039.
st_to_hir.cpp
956f049fd24eb5239361e68a1f27e1bebb3315a0 07-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Early return with visit_continue in loop_analysis::visit(ir_dereference_variable *)

Returning early with visit_continue_with_parent prevented the
then-statements and else-statements of if-statements such as the
following from being processed:

if (some_var) { ... } else { ... }

Fixes piglit test case glsl-fs-loop-nested-if and bugzilla #30030.
oop_analysis.cpp
0427228bbc241d0b76df853812d023273b496637 07-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Change grammar rules for selection statements to match the spec.

Fixes piglit test case loop-06.vert.

Unfortunately, causes 1 shift/reduce conflict.
lsl_parser.cpp
lsl_parser.h
lsl_parser.ypp
c47b289972a6c5ca0e30ff5618418e5ca91bd1ec 04-Sep-2010 Török Edvin <edwintorok@gmail.com> glsl2: check for _NumLinkedShaders being 0

Otherwise spring 0.82+.4.0 crashes when starting a game
because prog->_LinkedShaders[0] is NULL.

This also fixes piglit test cases glsl-link-empty-prog-0[12].
inker.cpp
1c009f970edaa4893c7c99a56da0e4425d01c4d8 05-Sep-2010 José Fonseca <jfonseca@vmware.com> glsl: Add new files to sconscript.
Conscript
9a3df46fbcfbad10163686ae4c034a3a55116947 05-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Only validate IR when a global 'debug' flag is set.

This extra validation is very useful when working on the built-ins, but
in general overkill - the results should stay the same unless the
built-ins or ir_validate have changed.

Also, validating all the built-in functions in every test case makes
piglit run unacceptably slow.
r_reader.cpp
79088746a231d361232fc87ab4d578b08c7ce2a7 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Run ir_validate on the generated IR.

It's just too easy to get something wrong in hand-written IR.
r_reader.cpp
2809d707231fba0e91abe1dd32e9f2d3284b9d3a 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Emit global variables at the top of the instruction list.

Since functions are emitted when scanning for prototypes, functions
always come first, even if the original IR listed the variable
declarations first.

Fixes an ir_validate error (to be turned on in the next commit).
r_reader.cpp
b758de16e3e6e27e9ead24aa6241b5d4db0d8836 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Drop support for reading the old assignment format.
r_reader.cpp
a878107d6cfc7e815f343613341c7924d0789d0b 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Regenerate autogenerated file builtin_function.cpp.
uiltin_function.cpp
bacbf941d25b8c2c22cc991384ac7304bb951a03 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Convert assignments to new format (with write mask).
uiltins/ir/atan
uiltins/ir/distance
uiltins/ir/equal
uiltins/ir/greaterThan
uiltins/ir/greaterThanEqual
uiltins/ir/lessThan
uiltins/ir/lessThanEqual
uiltins/ir/matrixCompMult
uiltins/ir/mix
uiltins/ir/notEqual
uiltins/ir/outerProduct
uiltins/ir/refract
uiltins/ir/smoothstep
uiltins/ir/step
uiltins/ir/transpose
03a6276477702404f5c7a4f5f2fbb713371c7eed 03-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Read the new assignment format (with write mask).

This preserves the ability to read the old format, for momentary
compatibility with all the existing IR implementations of built-ins.
r_reader.cpp
a71b46a8ad344a86de2b13fe0c283ac2036c5f76 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Track the current function and report it in error messages.
r_reader.cpp
a7dc8081b6e20fd05f99608aa0349a1eb75d914b 04-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Actually print the info log if reading a builtin failed.
uiltins/tools/generate_builtins.py
a5fd0396726d0142af364e3ea8ade470ff6c0559 03-Sep-2010 Brian Paul <brianp@vmware.com> exec_list: replace class with struct

To match the definition below.
ist.h
f061524f0737bf59dad6ab9bb2e0015df804e4b5 02-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use as_constant some places instead of constant_expression_value

The places where constant_expression_value are still used in loop
analysis are places where a new expression tree is created and
constant folding won't have happened. This is used, for example, when
we try to determine the maximal loop iteration count.

Based on review comments by Eric. "...rely on constant folding to
have done its job, instead of going all through the subtree again when
it wasn't a constant."
oop_analysis.cpp
oop_controls.cpp
4e5b41c2f6b6423d0df260a9dea7938546134ec6 28-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Allow copy / constant propagation into array indices
r_constant_propagation.cpp
r_copy_propagation.cpp
de7c3fe31a7b88a5392dceee3b13b45ed78cdeae 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add module to perform simple loop unrolling
akefile
akefile.am
lsl_parser_extras.cpp
oop_analysis.h
oop_controls.cpp
oop_unroll.cpp
ain.cpp
3bcfafcf0320ee5407716ff67062e80d162760d4 28-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Track the number of ir_loop_jump instructions that are in a loop
oop_analysis.cpp
oop_analysis.h
oop_controls.cpp
351525d534268b08c090f9ce42a67e9329a969ae 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> ir_expression: Add static operator_string method

I've used this in quite a few debug commits that never reached an
up-stream tree.
r.cpp
r.h
79082b8aca130ecdcaa1167a9961c16fc620f423 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> exec_node: Add insert_before that inserts an entire list
ist.h
7850ce0a9990c7f752e43a1dd88c204a7cf090aa 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Eliminate zero-iteration loops
oop_controls.cpp
8df2dbf91ddfd0c1590e33015e85470b67e69319 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Perform initial bits of loop analysis during compilation
lsl_parser_extras.cpp
ain.cpp
bfe3fbb38e0a3ae7c1efb74282628c2cc5abc3e0 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add module to suss out loop control variables from loop analysis data

This is the next step on the road to loop unrolling
akefile
akefile.am
oop_analysis.h
oop_controls.cpp
9434a0749f26c640305f68ef85d17a31063a5705 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add module to analyze variables used in loops

This is the first step eventually leading to loop unrolling.
akefile
akefile.am
oop_analysis.cpp
oop_analysis.h
53acbd87d712555f9e7a1c304843be7b39641413 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> ir_validate: Validate loop control fields in ir_loop
r_validate.cpp
3b85f1cc6cb12e9d4931e12cf29adde578f389fd 27-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add cmp field to ir_loop

This reprents the type of comparison between the loop induction
variable and the loop termination value.
r.cpp
r.h
r_clone.cpp
c8ee8e07f7cc8f18d367ffcec065b45f8a6976f4 06-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Set a flag when visiting the assignee of an assignment
r_hierarchical_visitor.cpp
r_hierarchical_visitor.h
r_hv_accept.cpp
r_rvalue_visitor.cpp
29eebe9a9a0486f12e33e2818c192ef683fdfede 17-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> exec_list: Add pop_head
ist.h
9710d272f71c95c8145999a31e2c47e1977c698e 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> ir_print_visitor: Print empty else blocks more compactly
r_print_visitor.cpp
6e3cbeb3614152ea3aa188666d6166b484ee3f56 02-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Update TODO file
ODO
f32d3df8ab2b7c6c746f46870edc4b284cea50ca 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Apply implicit conversions to structure constructor parameters.

The code for handling implicit conversions should probably get
refactored, but for now, this is easy.

Fixes piglit test constructor-26.vert.
st_function.cpp
st_to_hir.cpp
43a6200f3c3fb29d2e9654a293b2328cd6c0f64f 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Convert constant record constructor parameters to ir_constants.

I'm not sure if this is strictly necessary, but it seems wise.
st_function.cpp
cfe0dd5622a9b26e6df18801413ad8dc336f0c56 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Reject structure constructors that have too many arguments.

Fixes piglit test constructor-27.vert.
st_function.cpp
e466b182bbf21f62fe6542091f4af3275555db80 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Remove unnecessary glsl_symbol_table::get_function parameter return_constructors

Now that constructors are not generated as functions or stored in the
symbol table, there is no need to flag whether or not constructors
should be returned.
st_to_hir.cpp
lsl_symbol_table.cpp
lsl_symbol_table.h
4d6221f90df9d04e5edcdddb3b6f76c0cb175421 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Remove unused method glsl_type::generate_constructor
lsl_types.cpp
lsl_types.h
16d9ebb35771af2bc27024bb4b788ef6427a4f23 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Remove unused 'constructor' parameter from glsl_symbol_table::add_type
lsl_symbol_table.cpp
lsl_symbol_table.h
a789ca649cb143c0c5bf3209ff1bde398fbd777e 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Don't generate constructor functions for structures
st_to_hir.cpp
lsl_symbol_table.cpp
37200d83d3e61aa480e6dbb350e522bd0388644c 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Emit structure constructors inline

Fixes piglit test cases glsl-[fv]s-all-0[12].
st_function.cpp
39605587951aed546c14febcc26e5a479bf8d807 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix write mask in matrix-from-matrix constructors.

If the matrix being constructed was larger than the source matrix, it
would overwrite the lower-right part of the matrix with the wrong
values, rather than leaving it as the identity matrix.

For example, constructing a mat4 from a mat2 should only use a writemask
of "xy" when copying from the source, but was using "xyzw".

Fixes the code generated by piglit test constructor-23.vert.
st_function.cpp
54b35e673596d767a13f06f4d7ec1089e18fd46e 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add proper handling for constant matrix-from-matrix constructors.

Fixes piglit test case constructor-21.vert and changes
constructor-22.vert to give the correct output.
r.cpp
1f7c7df40f830e164f96df4468a2b4fa365c4b84 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Move generate_constructor_(matrix|vector) to ir_constant ctor.
st_function.cpp
r.cpp
550237eedd772487151565f64384d35c1bf695a6 02-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Fix check for "too few components".

This was triggering even for matrix-from-matrix constructors. It is
perfectly legal to construct a mat3 from a mat2 - the rest will be
filled in by the identity matrix.

Changes piglit test constructor-23.vert from FAIL to PASS, but the
generated code is incorrect.
st_function.cpp
ee88c4664016b11359c391cc62296bcbfcc5decd 01-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Remove bogus cases from generate_constructor_matrix.

There are no integer matrix types, so switching on them is silly.
st_function.cpp
0181385f36463ff03f4ed657b180acd8567c05d4 01-Sep-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Add forgotten implementations of equal/notEqual on bvecs.
uiltin_function.cpp
uiltins/ir/equal
uiltins/ir/notEqual
a35faa6a41eb8a240f8e6086853653e9a21e75bd 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Perform algebraic simplifications on logical binary operators

Reduces glsl-vs-all-01 from 42 Mesa IR instructions (including the
END) to 17.
r_algebraic.cpp
a4262874f84e25412cb9bc53b3f1771e4017e27c 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Allow ir_constant::zero to create boolean constants
r.cpp
63b80f8cc181ded154668e60ac2cf0a6a82d118f 01-Sep-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Disallow function declarations within function definitions in GLSL 1.20

The GLSL 1.20 spec specifically disallows this, but it was allowed in
GLSL 1.10.

Fixes piglit test cases local-function-0[13].frag and bugzilla #29921.
st_to_hir.cpp
16c733495d74d8c2443aa915a55df97c02b415c7 01-Sep-2010 Brian Paul <brianp@vmware.com> glsl2: fix bug in atan(y, x) function

When x==0, the result was wrong. Fixes piglit glsl-fs-atan-1.shader_test
uiltin_function.cpp
uiltins/ir/atan
a6c3cd5ca6822da2ec6e869c7bc2b8ac64c177f2 31-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Write vector constructor constants in a single assignment

Make two passes over the constructor parameters. Write all of the
constants in a single write, then write the non-constants one at a
time. This causes the fragment shader

varying float g;
void main()
{
gl_FragColor = vec4(0.0, g, 0.0, 1.0);
}

to generate

(function main
(signature void (parameters )
(
(declare (temporary ) vec4 vec_ctor@0x8580058)
(assign (constant bool (1)) (xzw) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) )
(assign (constant bool (1)) (y) (var_ref vec_ctor@0x8580058) (swiz xxxx (var_ref g@0x8580218) ))
(assign (constant bool (1)) (xyzw) (var_ref gl_FragColor@0x84d32a0) (var_ref vec_ctor@0x8580058) )
))
)

instead of

(function main
(signature void (parameters )
(
(declare (temporary ) vec4 vec_ctor@0x8580058)
(assign (constant bool (1)) (x) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) )
(assign (constant bool (1)) (y) (var_ref vec_ctor@0x8580058) (swiz xxxx (var_ref g@0x8580218) ))
(assign (constant bool (1)) (z) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) )
(assign (constant bool (1)) (w) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) )
(assign (constant bool (1)) (xyzw) (var_ref gl_FragColor@0x84d32a0) (var_ref vec_ctor@0x8580058) )
))
)

A similar optimization could be done for matrix constructors, but it
is a little more complicate there.
st_function.cpp
1eea96326fa652029e3898e104c715e5464f11e4 31-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Add support for bit-wise operators (but not shifts).

Previously, using bit-wise operators in some larger expression would
crash on a NULL pointer dereference. This code at least doesn't crash.

Fixes piglit test bitwise-01.frag.
st_to_hir.cpp
2619b1c96feed72444499021d8a870eab1c37e00 31-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> linker: Require an exact matching signature when looking for prototypes.

Fixes piglit test glsl-override-builtin. The linker incorrectly found
the prototype for the float signature, rather than adding a new
prototype with the int return type. This caused ir_calls with type int
to have their callees set to the float signature, triggering an assert.
ink_functions.cpp
df869d916308759fbacb227f60b1b6eda73131e2 31-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Handle varying arrays, matrices, and arrays of matrices

Fixes piglit test case glsl-array-varying-01.
inker.cpp
8b3d36d56378355f188dd419e35676b2e4086a73 30-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Clear the static values of builtin function profiles at release.

When releasing the builtin functions, we were just freeing the memory,
not telling the builtin function loader that we had freed its memory.
I wish I had done ARB_ES2_compatibility so we had regression testing
of this path. Fixes segfault on changing video options in nexuiz.
uiltin_function.cpp
uiltins/tools/generate_builtins.py
33fe364e5aa7de3ce5f46077ff0868dcec4084bb 30-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated files changed by previous commit
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
bea3963f59fb8da0687c3e3fbc6f15de8be7fddb 30-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Parse #pragma lines

All pragmas are currently ignored. Also, the error messages when a
pragma is used incorrectly (i.e., '#pragma debug(on)' inside a
function) are crap, but I think this is sufficient for now.

Fixes piglit test cases pragma-0[1-8].(vert|frag).
lsl_lexer.lpp
lsl_parser.ypp
ccd8b935e484d267ea864b5e8c65f826d015f708 30-Aug-2010 José Fonseca <jfonseca@vmware.com> glsl: Silence unused variable warning.
lsl_symbol_table.cpp
a2711d69686a6c7f2cabe174cfefeefc718ce335 30-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Treat sized and unsized array types as the same

If two shaders contain variables declared with array types that have
the same base type but one is sized and the other is not, linking
should succeed. I'm not super pleased with the way this is
implemented, and I am more convinced than ever that we need more
linker tests. We especially need "negative" tests.

Fixes bugzilla #29697 and piglit test glsl-link-array-01.
inker.cpp
0c93e69b25559225d3124d5a0deaaeceabf8cb12 29-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Initialize data in ast_function_expression::hir.

Completely initialize data that is passed to ir_constant constructor.

Fixes piglit glsl-orangebook-ch06-bump valgrind uninitialized variable
error on softpipe and llvmpipe.
st_function.cpp
30a086552827b82738421ff2d562e3c8c1da2735 29-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Completely initialize value member in ir_constant constructor.

The
ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
did not completely initialize the entire value member.

Fixes piglit glsl-fs-sampler-numbering-2 valgrind uninitialized value
error in softpipe and llvmpipe.
r.cpp
2d0ef6bfee64b6889cbfb69762f167a6dfc20131 29-Aug-2010 Vinson Lee <vlee@vmware.com> 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.
r_constant_expression.cpp
b43611b79c1f0a5caff80c17c9e7840a718f07c9 29-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Initialize data in read_constant.

Completely initialize data that is passed into a ir_constant constructor.

Fixes piglit glsl-fs-mix valgrind uninitialized variable error on
softpipe and llvmpipe.
r_reader.cpp
f67400d4671ce7776f71cafced6546dddecba42c 29-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Initialize the rest of values of ir_constant::value.

Fixes valgrind uninitialized value errors in the piglit shader tests for
softpipe and llvmpipe.
r.cpp
120d5a95cb983b0b983089ba415486c55a9196e3 19-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Decompose matrix comparison into vector operations
r_mat_op_to_vec.cpp
c7adb4ff1e7183d476680617d130b7dfed80d6c0 28-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Rename a couple of common variable names in mat_op_to_vec.

It was easy while typing implementations to accidentally overwrite the
original expression or assignment variables.
r_mat_op_to_vec.cpp
3c96ef1f07f202312e1b7ae349b8bcbe7aed9e75 28-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Make mat_op_to_vec allocate out of the IR's parent.

This will reduce memory consumption of compiled shaders by not
dragging optimized-out children around.
r_mat_op_to_vec.cpp
681492cbe2b3bef26b11bf978e4d0a502a37bc35 28-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Regenerate for double destroy fix.
uiltin_function.cpp
d539c69044c735618bf85485df7733e9f0491d18 28-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Protect against double compiler-destroy.

DRI was doing teardown when we close the last screen, then an atexit()
was added to call it as well.
uiltins/tools/generate_builtins.py
b820bf979a1c308d8d6fe6ad89e8ae7c77226603 27-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: restructure header file for C++ and C inclusion

As it was, the header could not be cleanly #included by a C source.
lsl_parser_extras.h
1be5d1c887b3308865c8f4770138a9d70251392f 27-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: remove 'extern' keyword in .c file
lcpp/pp.c
2db7bb9c665d13fd067109b1171eedd92764791d 26-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Add a quick hack to constant folding to reduce duplicated work.

Reduces runtime of glsl-max-varyings 92% on my system.
r_constant_folding.cpp
58087b8d2722c3a8d1cb09af6c7f8d6726f34f73 26-Aug-2010 José Fonseca <jfonseca@vmware.com> scons: Add glsl_symbol_table.cpp
Conscript
de3b40d8cdc42cc1cd71dd65c90d6d569d922fc6 26-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Remove a couple FINISHME comments that have already been resolved
st_to_hir.cpp
a044285e25615f2d97636fe3ba47d580c3537bc4 23-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Move built-ins to live beyond the global scope.

Per the GLSL 1.20 specification (presumably a clarification of 1.10).

Also, when creating user functions, make a new ir_function that shadows the
built-in ir_function, rather than adding new signatures. User functions
are supposed to hide built-ins, not overload them.

Fixes piglit tests redeclaration-{04, 12, 14}.vert.
st_to_hir.cpp
b6f15869b324ae64a00d0fe46fa3c8c62c1edb6c 21-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> 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>
r.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_import_prototypes.cpp
r_print_visitor.cpp
r_reader.cpp
inker.cpp
5d25746640ee27882b69a962459727cf924443db 24-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refactor variable declaration handling.

Moving the check for an earlier variable declaration helps cleanly
separate out the re-declaration vs. new declaration code a bit. With
that in place, conflicts between variable names and structure types or
function names aren't caught by the earlier "redeclaration" error
message, so check the return type on glsl_symbol_table::add_variable
and issue an error there. If one occurs, don't emit the initializer.

Fixes redeclaration-01.vert and redeclaration-09.vert.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
ac2376e6f51677ab321930b0200a79d1683cfbba 26-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Don't add overloads to existing structure constructors.

Instead, make a new ir_function and try to add it to the symbol table.

Fixes piglit test redeclaration-08.vert.
st_to_hir.cpp
lsl_symbol_table.cpp
lsl_symbol_table.h
e09591317b2470fe9c104606577d4e10255727c0 26-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Remove name_declared_this_scope check when adding functions.

Instead, rely on the symbol table's rules.

Fixes redeclaration-02.vert.
st_to_hir.cpp
e9c7ceed27f6811ad1cae46c93ce9bc3fb3668d8 22-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Use a single shared namespace in the symbol table.

As of 1.20, variable names, function names, and structure type names all
share a single namespace, and should conflict with one another in the
same scope, or hide each other in nested scopes.

However, in 1.10, variables and functions can share the same name in the
same scope. Structure types, however, conflict with/hide both.

Fixes piglit tests redeclaration-06.vert, redeclaration-11.vert,
redeclaration-19.vert, and struct-05.vert.
akefile
st_to_hir.cpp
uiltin_function.cpp
uiltins/tools/generate_builtins.py
lsl_parser.cpp
lsl_parser.h
lsl_parser.ypp
lsl_symbol_table.cpp
lsl_symbol_table.h
lsl_types.cpp
lsl_types.h
9fd2a8d6923a8a7218a714622586bb1dbaaebad5 26-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Move ir_expression_flattening to using the rvalue visitor class.

The previous implementation was missing handling of some rvalues, such
as "if" conditions, leading to glsl-mat-int-from-ctor-* not getting
caught.
r_expression_flattening.cpp
c735d85395f8f0c0a71b04ebc728390970271fe2 26-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Don't consider things with a type containing a sampler as an lvalue.

We had ad-hoc handled some common cases by flagging sampler-typed
variables as read_only, and rejected initializers of samplers.
However, people could sneak them in in all sorts of surprising ways,
like using whole-array or structure assignment.

Fixes:
glslparsertest/glsl2/sampler-01.frag
glslparsertest/glsl2/sampler-03.frag
glslparsertest/glsl2/sampler-04.frag
glslparsertest/glsl2/sampler-06.frag

Bug #27403.
r.cpp
5226f8c7b0025031e8540adc93ecfe0b36b8f90f 25-Aug-2010 Aras Pranckevicius <aras@unity3d.com> glsl: fix crash with variable indexing into array in a struct

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
st_to_hir.cpp
0924ba0c3496160a134d37cec800f902ae805b9c 24-Aug-2010 Eric Anholt <eric@anholt.net> ir_to_mesa: Convert this code to using linker.cpp's uniform locations.

Fixes: glsl-fs-uniform-array-4.
inker.cpp
45388b5467d66a887e9c76b66ae126ec07d4125a 24-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Make uniform linking generate separate uniforms for struct members.

This is a step towards making the linker code usable as our uniform
setup, instead of having it wedged into ir_to_mesa.cpp.
inker.cpp
653ddaab2636764b9e7999fa39b37edde7fe7c6d 25-Aug-2010 Aras Pranckevicius <aras@unity3d.com> glsl/mesa: fixes for MSVC

Signed-off-by: Brian Paul <brianp@vmware.com>
lcpp/pp.c
7de4d8fe11c53e59265b8a4252ab9940ffcc9929 25-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Don't dead-code eliminate a uniform initializer.

Partial fix for glsl-uniform-initializer-5.
r_dead_code.cpp
81137623e55bb003d2479385547028661c71b415 24-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: rename local variable_entry class

With MSVC it seems that this class and its constructor is colliding
with the one in ir_variable_refcount.cpp. Rename the class here to
avoid the collision.

This is a bit of a hack. Can the two variable_entry classes be merged
and shared?
r_structure_splitting.cpp
2eb8b2d3bb68cef1d3fc431debe1b18f6c017aeb 24-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: move constructor into .cpp file to work around compiler bug

Fixes fd.o bug 29770

The refcount==0 assertion only failed on some systems. One example
being 32-bit Linux with gcc 4.4.4.
r_variable_refcount.cpp
r_variable_refcount.h
c8b26c63fdad84d311748a24972146b6a371ab31 24-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Add assert to check variable_entry referenced_count after construction.

A variable_entry after construction should have its referenced_count
member set to 0. However, occassionally this isn't the case and
entry->referenced_count has been observed to be a garbage value. This
leads to crashes of several tests in the Piglit test suite.

This patch adds an assert to check that a variable_entry instance has
its referenced_count member initialized to 0 after construction.
r_variable_refcount.cpp
f122dba59a753e8672cb7cc9b9109b81e0ab1b1c 24-Aug-2010 Dave Airlie <airlied@redhat.com> glsl: make 'make clean' work properly.

this has make clean remove all the objects.
akefile
e5df3cc286fa2607897944d478081014929b38ec 24-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Silence unused variable warning.

The variable is used but only in the body of an assert.
lsl_types.cpp
bfd7c9ac228c7ed8aec04c3b3aa33f40ee00b035 23-Aug-2010 Chia-I Wu <olv@lunarg.com> glsl: Include main/core.h.

Make glsl include only main/core.h from core mesa.
st_function.cpp
st_to_hir.cpp
uiltin_function.cpp
uiltin_variables.h
uiltins/tools/generate_builtins.py
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
lsl_parser_extras.cpp
lsl_types.cpp
ir_field_selection.cpp
r.cpp
r_constant_expression.cpp
r_explog_to_explog2.cpp
r_set_program_inouts.cpp
r_variable.cpp
ink_functions.cpp
inker.cpp
rogram.h
8dd619ba6825e673a357336b69c96accaa96a7ef 24-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Rely on talloc_autofree_context() instead of trying to free on our own.

Because the static types talloc their names at dlopen time,
talloc_freeing the types at DRI driver screen teardown means that if
the screen gets brought back up again, the names will point at freed
memory. talloc_autofree_context() exists to do just what we want
here: Free memory referenced across the program's lifetime so that we
avoid noise in memory leak checkers.

Fixes: bug #29722 (assertion failure in unigine).
lsl_types.cpp
e11757bb896e3dadc54fb3d18adf4b71e3e883b3 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: When unable to assign the initializer for a const variable, set it to 0.

This prevents assertion failures or cascading errors after we've
logged the fact that we were unable to handle the initializer.

Fixes unsized-array-non-const-index-2.vert
st_to_hir.cpp
76e96d74f49cc262ceaf2ed6c48d2f4ed21d219f 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Cleanly fail when a function has an unknown return type.

Bug #29608.
st_to_hir.cpp
b75645d8adf88ef237c3f835b6190e8113452b09 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Rebuild builtins for any() change.
uiltin_function.cpp
5e9ac94cc44ef4f97063d7b696411b2a4be16f36 23-Aug-2010 Eric Anholt <eric@anholt.net> 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)
EADME
uiltins/ir/any
r.cpp
r.h
r_constant_expression.cpp
r_validate.cpp
47003a8f653db881fbafc96fca93aba38ea3ebc2 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Regenerate builtins with the new sorting.
uiltin_function.cpp
18a60239001c27ff98739865d5fc70fd3d011b2e 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Count function call outvals as writing to variables for linker checks.

Fixes: glsl-vs-position-outval. Bug #28138 (regnum online)
inker.cpp
6dad5a4e8d5c4ea90bb9342e329defb9c8eb2092 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Include imports.h to get snprintf wrapper for MSVC

Signed-off-by: José Fonseca <jfonseca@vmware.com>
lsl_types.cpp
r_explog_to_explog2.cpp
6355ae2b80a01b1d58824ffeae0c638d917519c0 23-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> generate_builtins.py: Generate output in sorted order.
uiltins/tools/generate_builtins.py
61f73fec532b24ef5ec4b5baef81f5e6b9f20918 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Make standalone preprocessor work with a tty as stdin

Previously glcpp would silently abort if it couldn't fstat the file being
read, (so it would work with stdin redirected from a file, but would not
work with stdin as a tty). The stat was so that glcpp could allocate
a buffer for the file content in a single call.

We now use talloc_realloc instead, (even if the fstat is
possible). This is theoretically less efficient, but quite irrelevant,
(particularly because the standalone preprocessor is used only for
testing).
lcpp/glcpp.c
21560c40e8aa98624a225752b98babc7ae2938d5 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix test suite to avoid flagging failed tests as valgrind errors.

We recently added several tests that intentionally trigger
preprocessor errors. During valgrind-based testing, our test script
was noticing the non-zero return value from the preprocessor and
incorrectly flagging the valgrind-based test as failing.

To fix this, we make valgrind return an error code that is otherwise
unused by the preprocessor.
lcpp/tests/glcpp-test
cf8bb19a114d753bca94f920b87dcf51aa26af99 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix segfault in standalone preprocessor for "file not found", etc.

This error message was missing so that the program would simply
segfault if the provided filename could not be opened for some reason.

While we're at it, we add explicit support for a filename of "-" to
indicate input from stdin.
lcpp/glcpp.c
eab206510fc76407ee8b18aacafadd0d5406e483 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Update generated glcpp-lex.c for the last two changes.

This fixes both "#line 0" and "#line XXX YYY" as described in the two
most recent commits.
lcpp/glcpp-lex.c
c2280e63817238bb969b20605c7d8dab4ddf1721 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix handling of "#line 0"

The existing DECIMAL_INTEGER pattern is the correct thing to use when
looking for a C decimal integer, (that is, a digit-sequence not
starting with 0 which would instead be an octal integer).

But for #line, we really want to accept any digit sequence, (including
"0"), and always interpret it as a decimal constant. So we add a new
DIGITS pattern for this case.

This should fix the compilation failure noted in bug #28138

https://bugs.freedesktop.org/show_bug.cgi?id=28138

(Though the generated file will not be updated until the next commit.)
lcpp/glcpp-lex.l
ff10d239af3b48f4ba13a0ef947e97d3302ea818 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix source numbers set with "#line LINE_NUMBER SOURCE_NUMBER"

Previously, the YY_USER_ACTION was overwriting the yylloc->source value
in every action, (after that value had been carefully set by the handling
of the #line directive). Instead, we want to initialize it once in
YY_USER_INIT and then not touch it at all in YY_USER_ACTION.
lcpp/glcpp-lex.l
2a9e791fdeb45080a98042d41c153ea19c17caae 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Add new test for #line directive.

This test exposes two current bugs:

1. The source number is not being correctly emitted in error
messages (instead, it's always 0).

2. A directive of "#line 0" is resulting in the following
parse error:

preprocessor error: Invalid tokens after #
lcpp/tests/091-hash-line.c
lcpp/tests/091-hash-line.c.expected
c15f04b326aafc27aa2e508ab88bf209c829abd7 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Update README file (new specifications and fewer limitations).

The README file had grown a little bit stale. We've been using newer
versions of both the GLSL and C99 specifications, so list those. Also,
several of the documented known limitations have since been fixed, so
remove those.
lcpp/README
0acd68c4050fea82797f80ad90212926df4cf001 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Add test for the #error directive.

This directive is already implemented nicely, but wasn't previously tested.
It will be convenient to use this directive in further tests that rely
on error messages, (such as ensuring that #line correctly sets the line
number in the error message).
lcpp/tests/090-hash-error.c
lcpp/tests/090-hash-error.c.expected
a721abfbd1724e83381b46fc670bb38fbde76f69 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Trim the size of uniform arrays to the maximum element used.

Fixes glsl-getactiveuniform-array-size.
st_to_hir.cpp
inker.cpp
ea709696185846c876581e1c41a21921826823ec 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add missing sig_iter.next() to the no-constant-folding-to-outvals fix.
r_constant_folding.cpp
r_tree_grafting.cpp
428a3cd2d537a42c8a01765a5a53dca139e07443 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Don't constant-fold in a constant in place of a function outval.
r_constant_folding.cpp
6606fde3ec18288ecc4c6ce6d3fd32224a6c5248 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Convert constant folding to the rvalue visitor.

This should be mostly a noop, except that a plain dereference of a
variable that is not part of a constant expression could now get
"constant folded". I expect that for all current backends this will
be either a noop, or possibly a win when it provokes more
ir_algebraic. It'll also ensure that when new features are added,
tree walking will work normally. Before this, constants weren't
getting folded inside of loops.
r_constant_folding.cpp
137b8397fa5cc5d70e86a4b14d6be9326340f584 23-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Don't tree-graft in an expression in place of a function outval.

Fixes: glsl-constant-folding-call-1 (bug #29737)
r_tree_grafting.cpp
639cdd3782c40c422c33c907949376c735d9340c 23-Aug-2010 Eric Anholt <eric@anholt.net> mesa: AC_SUBST the talloc libs/cflags so the ./configure results are saved.

I had used pkg-config from the Makefile because I didn't want to screw
around with the non-autoconf build, but that doesn't work because the
PKG_CONFIG_PATH or TALLOC_LIBS/TALLOC_CFLAGS that people set at
configure time needs to be respected and may not be present at build
time.

Bug #29585
akefile
56176f00f59624ef1335175b3669081e2f3e83ed 22-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Silence uninitialized variable warning.

i686-apple-darwin10-gcc-4.2.1 generated the following warning.
warning: 'score' may be used uninitialized in this function

GCC 4.4.3 on Linux didn't generate the above warning.
r_function.cpp
13b3d4c23d9d088a5a2b3bd657f1f163e42e4d8b 22-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Silence unused variable warning.

The variable is actually used but only in the body of an assert.
st_to_hir.cpp
e511a35fc53fb75a2401d8a94c0c35634175c575 22-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Handle array declarations in function parameters.

The 'vec4[12] foo' style already worked, but the 'vec4 foo[12]' style
did not. Also, 'vec4[] foo' was wrongly accepted.

Fixes piglit test cases array-19.vert and array-21.vert.

May fix fd.o bug #29684 (or at least part of it).
st_to_hir.cpp
f7188ac9ce75638003c916c9d5d42a75365ff1c4 21-Aug-2010 Vinson Lee <vlee@vmware.com> generate_builtins.py: Remove unused import sys.
uiltins/tools/generate_builtins.py
7f80041efae5be95ef53b8164e67027d234f9574 20-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> Delete more vestiges of the old shader compiler.
pps/.gitignore
pps/Makefile
pps/compile.c
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
284ce20901b0c2cfab1d952cc129b8f3cd068f12 20-Aug-2010 Eric Anholt <eric@anholt.net> Remove remnants of the old glsl compiler.
l/Makefile
l/sl_cl_parse.c
l/sl_cl_parse.h
p/Makefile
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_define.c
p/sl_pp_dict.c
p/sl_pp_dict.h
p/sl_pp_error.c
p/sl_pp_expression.c
p/sl_pp_expression.h
p/sl_pp_extension.c
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_pragma.c
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_public.h
p/sl_pp_purify.c
p/sl_pp_purify.h
p/sl_pp_token.c
p/sl_pp_token.h
p/sl_pp_token_util.c
p/sl_pp_token_util.h
p/sl_pp_version.c
edd180f03216d2fcb2771aeea34e7015fb2b83c3 20-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Reject function names that start with "gl_".

Fixes piglit test redeclaration-03.vert.
st_to_hir.cpp
826a39cb14244820e8539a2328bb52447348f184 20-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Fix crash when a function shadows a variable.

The code would attempt to add a new signature to the ir_function, which
didn't exist. Simply bailing out/returning early seems reasonable.

Fixes piglit test redeclaration-02.vert, and fixes a crash in
redeclaration-03.vert (the test still fails).
st_to_hir.cpp
365ce61997a28a0c0dad79e7d3f7616e57f105f5 19-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Replace sscanf in s_expression reader with strspn and strcspn.

This seems to give roughly a 20% speedup.
_expression.cpp
_expression.h
f1d5a9419784e939da1a4bcc482567f315da541a 19-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Also strdup the names of uniform list entries for >vec4 types.

Fixes double-free since the fix to free all of the uniform list.
inker.cpp
bd7853768dd7ad52604e3b636ae71dacaa7352fe 19-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Refresh autogenerated lexer.
lcpp/glcpp-lex.c
9cf62bdfeb3982405b9360500d7e0fa52036f38f 19-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add basic #line support (adapted from the main compiler).
lcpp/glcpp-lex.l
b83846475bac76268d75f53632faf8aad8cad02c 19-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Free the shader compiler at dri screen destruction.

Hooray, we can valgrind again without adding suppressions. This also
adds an interface for use by an implementation of
glReleaseShaderCompiler().
lsl_parser_extras.cpp
lsl_parser_extras.h
4532feba14fcf4e39ea6e44dd2b6a290697bbd50 19-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Fix leak-causing typo in destructor that made it another constructor.
r_set_program_inouts.cpp
352e62c3c26c75ddce1345962339f78c64d0aa95 19-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Fix uninitialized member in ir_hierarchical_vistor constructor.

Class member base_ir was not initialized by the default constructor.
r_hierarchical_visitor.cpp
e271384219ebc1f9e8afb63b20256f9d56102592 18-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Garbage collect old prototype for ir_to_mesa.
lsl_parser_extras.h
5d0f430e8ed01db29d11d22e4b6c3760d8c39f8f 18-Aug-2010 Eric Anholt <eric@anholt.net> mesa: Free old linked shaders when relinking new shaders.
inker.cpp
ain.cpp
rogram.h
0b09e6410f1173c2f69b601e43c5b14d8ad97345 18-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Fix copy'n'paste hilarity leading to leaking in the refcount visitor.
r_dead_code.cpp
r_variable_refcount.h
665d75cc5a23f8024034d0c4176fb281f94a30e9 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Fix scoping bug in if statements.

Fixes glslparsertest/glsl2/scoping-01.frag (successfully compiled but
should've failed) and scoping-02.frag (assertion triggered).
st_to_hir.cpp
cf37ba34301374aecf16fea659ac70b000a11a55 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
011be6b5948e66adb468aef292a7c8e9be600a89 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> generate_builtins.py: Clean up generated output a bit.

This should make it easier to diff the output, clean up some of the
insane whitespace, and make the strings a bit smaller.

We'll probably need to split up the prototype strings eventually, but
for now, this gets it under the 65K mark.
uiltins/tools/generate_builtins.py
08a84c6a4aa8f69af6b6981f62d81dd0424dae4a 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl/builtins: Add forgotten hyperbolic trig builtins in 1.30 profiles.
uiltins/profiles/130.frag
uiltins/profiles/130.vert
d12cb77d85ec726a67c2099c4105df63829b45a4 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> 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.
r_constant_expression.cpp
a57b1e579d1a76a813f48ae541a1edebb7f07607 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Regenerate builtin_function.cpp.
uiltin_function.cpp
f70ce12529cf76b8eefae9599b35323d87d3dbaa 18-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Fix cut and paste error in EXT_texture_array builtins.

Fixes fd.o bug #29629.
uiltins/profiles/EXT_texture_array.frag
uiltins/profiles/EXT_texture_array.vert
9751b4ec60291a5fc48fe9ef27324350d148f36e 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Refresh generated files.

After a recent change to glcpp-parse.y (adding "redefined macro" error).
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
3882cf21696d2576bd3d855dbc97c9354f72a15f 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Add support for "redefined macro" error.

Carefully avoiding printing any error when the new definition matches
the existing definition.

This fixes the recently-added 088-redefine-macro-legitimate.c and
089-redefine-macro-error.c tests as well as glsparsertest/preprocess1
in piglit.
lcpp/glcpp-parse.y
105e2137d67b98c24251be3586985fb61aeaf28a 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Add two new tests for testing redefined macros.

The specification says that redefining a macro is an error, unless the
new definitions is identical to the old one, (identical replacement
lists but ignoring differing amounts of whitespace).
lcpp/tests/088-redefine-macro-legitimate.c
lcpp/tests/088-redefine-macro-legitimate.c.expected
lcpp/tests/089-redefine-macro-error.c
lcpp/tests/089-redefine-macro-error.c.expected
97638aa77c509cd37dea499202d31357926a0e2a 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Allow standalone glcpp to accept a filename as first argument.

This is useful for debugging the preprocessor.
lcpp/glcpp.c
ce5d0a296c984a9b746f0b248f4cb10ed78bc647 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix 064-version.c expected result to track recent change.

In commit 6be3a8b70af4ba4fa4d037d54ecf6d5f055edbc9, the #version directive
was fixed to stop generating a spurious newline. Here we simply update
the expected result for the single test which includes a #version directive.
lcpp/tests/064-version.c.expected
b9892f22d18400db2f20f20b05c301248209bf48 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Regenerated glcpp-lex.c from previous commit.

The previous commit changed glcpp-lex.l so we commit the resulting
generated file here.
lcpp/glcpp-lex.c
eb26f0d5b68f0218d4c79c1825d0d9e6a905e199 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Don't include the newline when discarding single-line comments

Matching the newline here meant having to do some redundant work here,
(incrementing line number, resetting column number, and returning a
NEWLINE token), that could otherwise simply be left to the existing rule
which matches a newline.

Worse, when the comment rule matches the newline as well, the parser
can lookahead and see a token for something that should actually be skipped.

For example, in a case like this:

#if 0 // comment here
fail
#else
win
#endif

Both fail and win appear in the output, (not that the condition is being
evaluated incorrectly---merely that one token after the comment's newline
was being lexed/parse regardless of the condition).

This commit fixes the above test case, (which is also remarkably similar
to 087-if-comments which now passes).
lcpp/glcpp-lex.l
ede67e307142000a408e40b637132700a4dc2808 18-Aug-2010 Eric Anholt <eric@anholt.net> glcpp: Add testcase for #if handling bug that breaks Savage2.
lcpp/tests/087-if-comments.c
lcpp/tests/087-if-comments.c.expected
bdc0e5285a3d7d29b953970e43ca548cbc4e7e30 18-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Fix transpose of rows and cols

This error led to an assertion failure for some constructors of
non-square matrices. It only occured in matrices where the number of
columns was greater than the number of rows. It didn't even always
occur on those.

Fixes piglit glslparsertest case constructor-16.vert.
st_function.cpp
40e114b5dc60c5e196a86e33c2436b099ed9f392 17-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Demote user-defined varyings in the VS-only case

Fixes piglit test case glsl-vs-ff-frag and bugzilla #29623.
inker.cpp
0e6066df633f4594fd6fb8ceeb12b15561c57a48 17-Aug-2010 Eric Anholt <eric@anholt.net> glsl: When doing algebraic simplification, make sure the type still matches.

When simplifying (vec4(1.0) / (float(x))) to rcp(float(x)), we forgot
to produce a vec4, angering ir_validate when starting alien-arena.

Fixes:
glsl-algebraic-add-zero-2
glsl-algebraic-div-one-2
glsl-algebraic-mul-one-2
glsl-algebraic-sub-zero-3
glsl-algebraic-rcp-sqrt-2
r_algebraic.cpp
f166d94fac8383b4c56f899ead0b7c06151e16d9 17-Aug-2010 Eric Anholt <eric@anholt.net> glsl: Make ir_algebraic new expressions allocate out of the parent.

This could reduce the amount of memory used by a shader tree after
optimization, and increases consistency with other passes.
r_algebraic.cpp
664364052f362af2789e6b0fa88b6a5ba66ba936 17-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> ir_constant: Don't assert on out-of-bounds array accesses

Several optimization paths, including constant folding, can lead to
accessing an ir_constant array with an out of bounds index. The GLSL
spec lets us produce "undefined" results, but it does not let us
crash.

Fixes piglit test case glsl-array-bounds-01 and glsl-array-bounds-03.
r.cpp
6c03c576cc49bbb008de66d374f4302ff0fe0390 17-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> Merge branch 'glsl2'

Conflicts:
src/mesa/program/prog_optimize.c
a433cd286c60eb9d4c2114f042709eda0f3de676 17-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
2f9ecc818d67b8ea7496fd1dd0cb8bc7b9f8f8a4 17-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add builtins profile for GLSL 1.30.

Many functions are currently wrapped with #if 0 since we haven't
implemented them yet.
uiltins/profiles/130.frag
uiltins/profiles/130.vert
45d97dd6d5467d96acee1ba33052836b45668564 16-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Include compiler.h to avoid spurious warnings about INLINE
inker.cpp
d0a9cbd20ee0a1b5c350fed1c470946e4500f793 16-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Silence unused variable warning
r_structure_splitting.cpp
2e2614586225b3fff3c21f37817064a90dd320ad 16-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Refresh autogenerated lexer and parser.
lcpp/glcpp-lex.c
lcpp/glcpp-parse.c
6be3a8b70af4ba4fa4d037d54ecf6d5f055edbc9 16-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove spurious newline generated by #version handling.

This was causing line numbering to be off by one. The newline comes
from the NEWLINE token at the end of the line; there's no need to
insert one.
lcpp/glcpp-lex.l
lcpp/glcpp-parse.y
9349379d1acca23e7a2442549e49e9b58515d731 14-Aug-2010 José Fonseca <jfonseca@vmware.com> Revert "glsl2: Use stdint.h instead of inttypes.h"

This reverts commit a77a6bc008b3146c56431fa520a00e1f8dfa3938.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
r_function_inlining.cpp
r_validate.cpp
1cbcf6693aa490c4dcb56712bfb9998deb270f08 14-Aug-2010 José Fonseca <jfonseca@vmware.com> glsl: Standardize a few more uses of struct vs class keyword.
lsl_symbol_table.h
lsl_types.h
r.h
r_structure_splitting.cpp
r_tree_grafting.cpp
4b1721eaf35ccb60d90850ab34a99d6ab1f89a05 14-Aug-2010 José Fonseca <jfonseca@vmware.com> glsl: Silence gcc warning "control reaches end of non-void function".
r_clone.cpp
2322404b5537b04c111bb985e07826d6b898dbcf 14-Aug-2010 José Fonseca <jfonseca@vmware.com> scons: Add new source files.
Conscript
71a6dea0f56d4c90b5e07de85cbaac26055c9a63 14-Aug-2010 Vinson Lee <vlee@vmware.com> glsl: Clean up header file inclusion.
pps/compile.c
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
l/sl_cl_parse.c
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_define.c
p/sl_pp_error.c
p/sl_pp_expression.c
p/sl_pp_expression.h
p/sl_pp_extension.c
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_pragma.c
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_public.h
p/sl_pp_token_util.c
p/sl_pp_token_util.h
p/sl_pp_version.c
de33671a4f2ed1c47cb2c18a3f272d38b3000106 14-Aug-2010 Vinson Lee <vlee@vmware.com> glsl/cl: Add forward declaration.
l/sl_cl_parse.h
9364ad8528b8482afd01aab9b5ebe8c9176883df 14-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/Makefile: Add a 'make builtins' target.

This copies over a dummy builtin_functions.cpp and rebuilds a
bootstrapped version of the compiler, then uses that to generate the
proper list of builtins. Finally, it rebuilds the compiler with the new
list.

Unfortunately, it's no longer automatic, but at least it works.
akefile
43ff8f1a4b90554eae489cebb7e05f983dd9ad66 12-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Rework builtin function generation.

Each language version/extension and target now has a "profile" containing
all of the available builtin function prototypes. These are written in
GLSL, and come directly out of the GLSL spec (except for expanding genType).

A new builtins/ir/ folder contains the hand-written IR for each builtin,
regardless of what version includes it. Only those definitions that have
prototypes in the profile will be included.

The autogenerated IR for texture builtins is no longer written to disk,
so there's no longer any confusion as to what's hand-written or
generated.

All scripts are now in python instead of perl.
akefile
uiltin_function.cpp
uiltins/110/abs
uiltins/110/all
uiltins/110/any
uiltins/110/asin
uiltins/110/atan
uiltins/110/ceil
uiltins/110/clamp
uiltins/110/cos
uiltins/110/cross
uiltins/110/degrees
uiltins/110/distance
uiltins/110/dot
uiltins/110/equal
uiltins/110/exp
uiltins/110/exp2
uiltins/110/faceforward
uiltins/110/floor
uiltins/110/fract
uiltins/110/greaterThan
uiltins/110/greaterThanEqual
uiltins/110/inversesqrt
uiltins/110/length
uiltins/110/lessThan
uiltins/110/lessThanEqual
uiltins/110/log
uiltins/110/log2
uiltins/110/matrixCompMult
uiltins/110/max
uiltins/110/min
uiltins/110/mix
uiltins/110/mod
uiltins/110/noise_fake
uiltins/110/normalize
uiltins/110/not
uiltins/110/notEqual
uiltins/110/pow
uiltins/110/radians
uiltins/110/reflect
uiltins/110/refract
uiltins/110/sign
uiltins/110/sin
uiltins/110/smoothstep
uiltins/110/sqrt
uiltins/110/step
uiltins/110/tan
uiltins/110/textures
uiltins/110_fs/derivatives
uiltins/110_fs/textures
uiltins/110_vs/ftransform
uiltins/120/matrixCompMult
uiltins/120/outerProduct
uiltins/120/transpose
uiltins/130/clamp
uiltins/130/cosh
uiltins/130/equal
uiltins/130/greaterThan
uiltins/130/greaterThanEqual
uiltins/130/lessThan
uiltins/130/lessThanEqual
uiltins/130/max
uiltins/130/min
uiltins/130/mix
uiltins/130/notEqual
uiltins/130/sign
uiltins/130/sinh
uiltins/130/tanh
uiltins/130/texelFetch
uiltins/130/texture
uiltins/130/textureGrad
uiltins/130/textureLod
uiltins/130/textureProj
uiltins/130/textureProjGrad
uiltins/130/textureProjLod
uiltins/130_fs/texture
uiltins/130_fs/textureProj
uiltins/ARB_texture_rectangle/textures
uiltins/EXT_texture_array/textures
uiltins/EXT_texture_array_fs/textures
uiltins/ir/abs
uiltins/ir/acos
uiltins/ir/all
uiltins/ir/any
uiltins/ir/asin
uiltins/ir/atan
uiltins/ir/ceil
uiltins/ir/clamp
uiltins/ir/cos
uiltins/ir/cosh
uiltins/ir/cross
uiltins/ir/dFdx
uiltins/ir/dFdy
uiltins/ir/degrees
uiltins/ir/distance
uiltins/ir/dot
uiltins/ir/equal
uiltins/ir/exp
uiltins/ir/exp2
uiltins/ir/faceforward
uiltins/ir/floor
uiltins/ir/fract
uiltins/ir/ftransform
uiltins/ir/fwidth
uiltins/ir/greaterThan
uiltins/ir/greaterThanEqual
uiltins/ir/inversesqrt
uiltins/ir/length
uiltins/ir/lessThan
uiltins/ir/lessThanEqual
uiltins/ir/log
uiltins/ir/log2
uiltins/ir/matrixCompMult
uiltins/ir/max
uiltins/ir/min
uiltins/ir/mix
uiltins/ir/mod
uiltins/ir/noise1
uiltins/ir/noise2
uiltins/ir/noise3
uiltins/ir/noise4
uiltins/ir/normalize
uiltins/ir/not
uiltins/ir/notEqual
uiltins/ir/outerProduct
uiltins/ir/pow
uiltins/ir/radians
uiltins/ir/reflect
uiltins/ir/refract
uiltins/ir/sign
uiltins/ir/sin
uiltins/ir/sinh
uiltins/ir/smoothstep
uiltins/ir/sqrt
uiltins/ir/step
uiltins/ir/tan
uiltins/ir/tanh
uiltins/ir/transpose
uiltins/profiles/110.frag
uiltins/profiles/110.vert
uiltins/profiles/120.frag
uiltins/profiles/120.vert
uiltins/profiles/ARB_texture_rectangle.frag
uiltins/profiles/ARB_texture_rectangle.vert
uiltins/profiles/EXT_texture_array.frag
uiltins/profiles/EXT_texture_array.vert
uiltins/tools/builtin_function.cpp
uiltins/tools/generate_builtins.pl
uiltins/tools/generate_builtins.py
uiltins/tools/texture_builtins.py
r_reader.cpp
r_reader.h
d802ba110f78c3eee9541867cde819ada1b2c449 12-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Don't mark functions as defined if their body is empty.
r_reader.cpp
d01bf822dd7f28dc56705407e7c3b9de1f292794 14-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated file change by commit ab18be74

This would have been included in commit 23f6017d, but make wisely did
not regenerate the file when the .lpp file did not change.
lsl_lexer.cpp
8f8cdbfba43550d0b8985fb087961864e4cd92b6 13-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass to strip out noop swizzles.

With the glsl2-965 branch, the optimization of glsl-algebraic-rcp-rcp
regressed due to noop swizzles hiding information from ir_algebraic.
This cleans up those noop swizzles for us.
akefile
lsl_parser_extras.cpp
r_noop_swizzle.cpp
r_optimization.h
42cab131dac469475c67ab38a2c29f2f66e6ff49 14-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Convert ir_constant_propagation to ir_rvalue_visitor.

This one is a little tricky because of the LHS handling.
r_constant_propagation.cpp
b3b0cf6a4c6b23e0ebe7e5f5ab1b7cacf27268b1 14-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add a generic visitor class to call back with pointers to each rvalue.

I keep copy and pasting this code all over, so consolidate it in one
place.
akefile
r_algebraic.cpp
r_rvalue_visitor.cpp
r_rvalue_visitor.h
r_structure_splitting.cpp
013bbbbb0ac52a12d1e4413700dc40dee70186f8 11-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add support for ir_unop_neg to ir_mat_op_to_vec
r_mat_op_to_vec.cpp
2f4fe151681a6f6afe1d452eece6cf4144f44e49 10-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Move the common optimization passes to a helper function.

These are passes that we expect all codegen to be happy with. The
other lowering passes for Mesa IR are moved to the Mesa IR generator.
lsl_parser_extras.cpp
r_optimization.h
inker.cpp
c55aa4292f35a6d08b0660e23f248a37988a5f99 14-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Refresh autogenerated bison parser.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
07ca55b7fa09b8b5c08f8e2e45f9060020593783 14-Aug-2010 Vinson Lee <vlee@vmware.com> Fix an MSVC build error (bugzilla 29570).
lcpp/glcpp-parse.y
768b55a5268572ff9fd03e57e92775882eb0a821 14-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Remove unnecessary use of 'struct' before type names

In C++ you don't have to say 'struct' or 'class' if the declaration of
the type has been seen. Some compilers will complain if you use
'struct' when 'class' should have been used and vice versa.

Fixes bugzilla #29539.
st.h
st_to_hir.cpp
lsl_parser.cpp
lsl_parser.h
lsl_parser.ypp
ir_field_selection.cpp
a77a6bc008b3146c56431fa520a00e1f8dfa3938 14-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use stdint.h instead of inttypes.h
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
r_function_inlining.cpp
r_validate.cpp
23f6017d70a705479b9bc3a1bf2ef401ac519fb9 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated file changed by previous commit
lcpp/glcpp-lex.c
ab18be74ac5f95ba1ebe6a52259d77e0940b2dbd 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use --nounistd to fix MSVC build

Also remove the --never-interactive command line option for the
preprocessor lexer. This was already done for main compiler lexer.
akefile
lcpp/glcpp-lex.l
c33e78f62bed762d8e5987e111a6e0424dc26c76 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Assign attrib location 0 if gl_Vertex is not used

If gl_Vertex is not used in the shader, then attribute location 0 is
available for use.

Fixes piglit test case glsl-getattriblocation (bugzilla #29540).
inker.cpp
204d4cbea0de81f6f162ae0348e476de6c916ca8 13-Aug-2010 Jakob Bornecrantz <jakob@vmware.com> glsl2: Include string.h in preprocessor
lcpp/pp.c
103453659dbb21dd49e700e4b6ba9aac83b5a3f4 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated files changed by previous two commits
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
5c77efc0b28dceaa2420b900822f475422a378d1 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Avoid token name collisions with names used by Windows header files
lsl_lexer.lpp
lsl_parser.ypp
5b9f3db71996a1296c7da8501dd3b159bfe8c2b2 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Eliminate tokens for square matrix short names

MAT2 and MAT2X2, for example, are treated identically by the parser.
The language version based error checking (becuase mat2x2 is not
available in GLSL 1.10) is already done in the lexer.
lsl_lexer.lpp
lsl_parser.ypp
3a3cdb909da5b02edf921fcb5a009dfc2868d23d 13-Aug-2010 José Fonseca <jfonseca@vmware.com> scons: Build the new glsl2 code.
Conscript
0dc39f481ab98d2114590103928b7403386c13cf 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use MIN2 from macros.h instead of open coding it
st_function.cpp
261bbc011d11ab9e390cd5fe9f5151821eefaffa 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use Elements from main/compiler.h instead of open-coding
uiltin_function.cpp
uiltin_types.h
uiltins/tools/generate_builtins.pl
lsl_types.cpp
r_variable.cpp
4ca4edd20e10415d7aabcf2ba6ca89e9401854ef 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated file changed by previous commit
lcpp/glcpp-parse.y
188f60fb0576c8ac06638a8fd080a2ecc551919c 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add missing include of string.h

Makes the build happy on non-GCC platforms.
lcpp/glcpp-parse.c
5a805079a8d209e843661941730ecfebb65d2913 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Change command line options passed to flex

Remove --never-interactive because it is already specified in the
source using %option. Use -o instead of --outfile. Some of the
%option commands may also need to be removed for compatibility with
older versions (e.g., 2.5.4) of flex.

This should fix bugzilla #29209.
akefile
a43871f763043a2ed6f3ab9f52d3cff32c63e47e 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated files changed by previous commit
lsl_parser.cpp
lsl_parser.h
2fb94b37d2ace1170018cc36f50cf6e71fc708c4 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use bison command line option to set prefix

Bison version 2.3 doesn't seem to support %name-prefix in the source.

This should fix bugzilla #29207.
akefile
lsl_parser.ypp
db36e88052918ad383c3acdd24f2b9864e240ddb 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Commit generated files changed by previous commit
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
77215e7e7babe73e5d959ab5ad82054a8d73c538 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Emit error from lexer when illegal reserved word is encountered

Without this, the parser will generate obtuse, useless error
diagnostics when reservered word that are not used by the grammar are
encountered in a shader.

Fixes bugzilla #29519.
lsl_lexer.lpp
lsl_parser.ypp
202604e8160157e4e80b3458175e0170d168e557 12-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Don't declare a variable called sig that shadows the other one

Accidentally having a variable called 'sig' within an if-statement
cause the higher scope 'sig' to always be NULL. As a result a new
function signature was created for a function definition even when one
already existed from a prototype declaration.

Fixes piglit test case glsl-function-prototype (bugzilla #29520).
st_to_hir.cpp
da6b10a7eb26c8a13056cbae9015d5b84f134142 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix "unterminated if" diagnostic.

This was previously being appended to the output string *after* a copy
of the supposedly final string was made and handed to the caller. So
the diagnostic was never actually visible to the user.

We fix this by moving the check for an unterminated #if from
glcpp_parser_destroy to the calling function, preprocess.

This fixes the test case 083-unterminated-if.c.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
lcpp/pp.c
lcpp/tests/083-unterminated-if.c.expected
6b9e7b034ca5d10cd367a2388c5439cdb10a1a68 11-Aug-2010 Carl Worth <cworth@cworth.org> glccp: Regenerate glcpp-parse.c

Due to a recent change to glcpp-parse.y.
lcpp/glcpp-parse.c
253cad3f424f71f6984431e5edbde1694ccfae3f 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Add an explicit diagnostic for #if with no expression.

This is more clear than the previously-generated diagnostic which was
something confusing like "enexpected newline".

This change makse test 080-if-witout-expression.c now pass.
lcpp/glcpp-parse.y
lcpp/tests/080-if-without-expression.c.expected
624dd585c72103e5bffbc600cdf7bdfba5305a15 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Reword diagnostic for #elif with no expression

Rather than telling the user what to fix, the standard convention is to
describe what the detected problem is. With this change, test
081-elif-without-expression now passes.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
lcpp/tests/081-elif-without-expression.c.expected
cb5ea0c79bd74ea6263d54302ed19c243ceb05de 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Add several tests for diagnostics.

Which are proving to be useful since some of these tests are not yet
acting as desired, (in particular, the unterminated if test is not
generating any diagnostic).
lcpp/tests/070-undefined-macro-in-expression.c
lcpp/tests/070-undefined-macro-in-expression.c.expected
lcpp/tests/077-else-without-if.c
lcpp/tests/077-else-without-if.c.expected
lcpp/tests/078-elif-without-if.c
lcpp/tests/078-elif-without-if.c.expected
lcpp/tests/079-endif-without-if.c
lcpp/tests/079-endif-without-if.c.expected
lcpp/tests/080-if-without-expression.c
lcpp/tests/080-if-without-expression.c.expected
lcpp/tests/081-elif-without-expression.c
lcpp/tests/081-elif-without-expression.c.expected
lcpp/tests/082-invalid-paste.c
lcpp/tests/082-invalid-paste.c.expected
lcpp/tests/083-unterminated-if.c
lcpp/tests/084-unbalanced-parentheses.c
lcpp/tests/085-incorrect-argument-count.c
lcpp/tests/085-incorrect-argument-count.c.expected
lcpp/tests/086-reserved-macro-names.c
lcpp/tests/086-reserved-macro-names.c.expected
5a6285cc862df35ef5275c3858f833e0807dee14 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Regenerate glcpp-lex.c

After a recent change to glcpp-lex.l
lcpp/glcpp-lex.c
bc64b8980803a5ba1cc91c63dc2ed1517db800c6 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Initialize line and column numbers to 1, not 0.

Error messages make more sense this way since the convention is for
the first line of a file to be numbered from 1, rather than 0.
lcpp/glcpp-lex.l
2bcff4c879acec31ef0b39ecf04e9df41c5cbfab 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp-test: Capture the stderr output of the preprocessor.

This allows writing tests that verify diagnostics from the preprocessor.
lcpp/tests/glcpp-test
9f9386d22aca8d14d1b1e6d4de9b24dcb183ca10 11-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: added casts to silence warnings
lsl_types.cpp
r_dead_code.cpp
r_validate.cpp
d3b66be3c7a3e9e29913ea86880c516e2b7a3ce0 11-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: added casts to silence warnings
r_print_visitor.cpp
ffd3f15e965d451b1aef032015cc2edea66c30fa 11-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: add cast to silence warning
r_structure_splitting.cpp
d1dda951c85f65612ed6fe080728f67fdc93d232 11-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: move declarations before code
lcpp/pp.c
6dc89d221d43fad5f3edbb903997160af071bec0 11-Aug-2010 Brian Paul <brianp@vmware.com> glsl2: remove trailing comma to silence warning
r.h
8485f4d9aa6d98304bb0197dc4f1f357d81d1daa 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Clean up intermediate file when test suite is interrupted.

The glcpp-test script was leaving around bogus *.valgrind-errors files if
a valgrind test was interrupted.
lcpp/tests/glcpp-test
764e096647ec8c0f20ea3b5191499af806ad23f8 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Regenerate glcpp-parse.c

After a recent change to glcpp-parse.y
lcpp/glcpp-parse.c
48ba058e7a4b808271ca987b1553efd7e9792da9 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Additional fixes for not evaluating skipped #if/#elif expressions.

This adds a couple of test cases to expand our coverage of invalid #if and
being skipped, (either by being nested inside an #if/#elif that evaluates to
zero or by being after an #if/#elif that evaluates to non-zero).
lcpp/glcpp-parse.y
lcpp/tests/075-elif-elif-undef.c
lcpp/tests/075-elif-elif-undef.c.expected
lcpp/tests/076-elif-undef-nested.c
lcpp/tests/076-elif-undef-nested.c.expected
298a6fcddef6a91084ae921fca0b8640eb2e2a16 11-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp/tests: Commit forgotten file 074-elif-undef.c.expected.
lcpp/tests/074-elif-undef.c.expected
64b408529aefe0fb5968471431ec0a1b0abd7697 09-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Remove useless comments.
uiltins/tools/texture_builtins.py
9b7fd2099f926b9cc187382ca75eb8dedf3d37ca 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Discard output of cmp when running the test suite.

We're already using the return-value of cmp to print either PASS or
FAIL and in the case of failure, we're subsequently running and
showing the output of diff. So any warnings/errors from cmp itself are
not actually needed, and can be quite confusing.
lcpp/tests/glcpp-test
4f9a64407c948a7a46d23e8d4f7caae6d0e83232 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix expected result for the 064-version.c test.

Commit d4a04f315560704bf1103df0b93723e468725df7 caused this test case
to produce an additional blank line, which is otherwise harmless, but
does need to be reflected in the .expected file for the test to pass.
lcpp/tests/064-version.c.expected
e29cd391253230611a26ca58849a1169045dd795 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Regnerate glcpp-parse.c and glcpp-parse.h

After making a minor change to the .y file.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
485f84d36608b4545fc5a0061f9ab3ac71b9e36e 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Initialize location structure at beginning of parse.

Since we have a custom structure for YYLTYPE locations, we need to use
an %initial-action directive to avoid triggering use of uninitialized
memory when, for example, printing error messages.

We apparently don't yet have a test case that allowed valgrind to find
this bug for us, but valgrind found a similar problem in the other
parser, so we fix this one as well.
lcpp/glcpp-parse.y
a7d6c496cfe2165468c4151f0838ebfd2122a990 11-Aug-2010 Carl Worth <cworth@cworth.org> glsl2: Regenerate glsl_parser.cpp and glsl_parser.h

After making a minor change to the .y file.
lsl_parser.cpp
lsl_parser.h
60d8c46995aa9cf3f80592b9c9bb8e5be6e87502 11-Aug-2010 Carl Worth <cworth@cworth.org> glsl2: Initialize location structure at beginning of parse.

Since we have a custom structure for YYLTYPE locations, we need to use
an %initial-action directive to avoid triggering use of uninitialized
memory when, for example, printing error messages.

Thanks to valgrind for noticing this bug.
lsl_parser.ypp
0ff3b2b344b21ae4a7b62ebba22d7358755c8dfe 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Make ir_algebraic reassociate add/mul operands for constant folding.

It's rather easy to produce two constant multiplies separated by other
multiplies while writing a BRDF shader, and non-obvious enough in the
resulting codegen that I didn't catch it in my demo code until just
recently. Cuts 3 965 instructions from my demo (<1%), and 20 from
glsl-fs-raytrace (1.3%).
r_algebraic.cpp
5854d4583c6e8885185e12a0636f77489a62e24c 10-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass to transform ir_binop_sub to add(op0, neg(op1))

All the current HW backends transform subtract to adding the negation,
so I haven't bothered peepholing it back out in Mesa IR. This allows
some subtract of subtract to get removed in ir_algebraic.
akefile
r_optimization.h
r_sub_to_add_neg.cpp
inker.cpp
8bebbeb7c5b26ec9166a4644a2c051238d18509b 10-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add constant propagation.

Whereas constant folding evaluates constant expressions at rvalue
nodes, constant propagation tracks constant components of vectors
across execution to replace (possibly swizzled) variable dereferences
with constant values, triggering possible constant folding or reduced
variable liveness.
akefile
r_constant_propagation.cpp
r_optimization.h
inker.cpp
ain.cpp
2dd3ae0d4ae681cd7b6b28caf35ca45965621c79 09-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Teach copy propagation about "if" and "loop" instructions.

This lets us track copies across basic block boundaries. The loop
doesn't get a filled out list of available copies into it yet, though.

glsl-fs-raytrace drops from 585 to 535 Mesa IR instructions out of the
compiler, and it appears that Yo Frankie's largest shaders decrease in
Mesa IR count by about 10% as well.
r_copy_propagation.cpp
8aa7dbacaf61cb4dd9a436a66c138cb865d7406c 09-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
2eed82ebc0435da40dd5b588efc9bef0946e8497 07-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> texture_builtins.py: Fix cut and paste errors in function names.

Some signatures were being generated with the wrong function name.
uiltins/130/textureProjGrad
uiltins/130/textureProjLod
uiltins/tools/texture_builtins.py
dbff7b541e4be26cc9363956af8595ec052c4e56 07-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Use gl_DepthRange's proper name.

It was being incorrectly added as gl_DepthRangeParameters, which is the
type name, not the variable name.
r_variable.cpp
c88e60a27b8d5675cbf488e754537739c2c40bfd 09-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> ir_algebraic: Support other comparisons in ir_unop_logic_not
r_algebraic.cpp
fe277089c7a9bb402ef40d89f641b69fb508f2dc 09-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> ir_algebraic: Convert ir_unop_logic_not handler to use a switch statement

Currently only ir_binop_equal and ir_binop_nequal are supported, but
soon all of the relational operators will be added. Making this
change now will simplify those commits.
r_algebraic.cpp
3adce986c498539d9a5d8db95926e66e1315da03 09-Aug-2010 Aras Pranckevicius <aras@unity3d.com> glsl2: do not use __retval name; two underscores is reserved word according to GLSL spec (and Win7 ATI drivers do complain about that)
lsl_types.cpp
r_function_inlining.cpp
5023edaf5d037c9b71f1795ac4b890f175507576 09-Aug-2010 Aras Pranckevicius <aras@unity3d.com> glsl: fix missing return in ir_structure_splitting
r_structure_splitting.cpp
f8d2cfe4a699faebd42bd1874ef0329d37791dd7 09-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Handle plain variable copies in struct splitting.

glsl-fs-raytrace goes from 620 Mesa IR instructions out of the
compiler to 585.
r_structure_splitting.cpp
b7e63c34e74ecfb1c4af8132471ca9cb70d28d1f 07-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add the 1.30 reserved keywords.
lsl_lexer.cpp
lsl_lexer.lpp
lsl_parser.cpp
lsl_parser.h
lsl_parser.ypp
58f1ffdd7c64c0c0962d2aaacdde8f55edefbb2c 06-Aug-2010 Aras Pranckevicius <aras@unity3d.com> ir_function_inlining: Fix missing iter.next() in inlining sampler params.

Fixes glsl-fs-function-samplers.
r_function_inlining.cpp
63cddb27d7e0f8d3fd71ccdf719341432a0ca970 06-Aug-2010 Aras Pranckevicius <aras@unity3d.com> copy_propagation: do propagation into non-out call params
r_copy_propagation.cpp
925b49ff310bf0b307add7c34627cddf87e6a554 06-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass.

This lets us handle arrays much better than trying to work backwards
from assembly.

Fixes fbo-drawbuffers-maxtargets on swrast (i965 needs loop unrolling)
akefile
r.h
r_set_program_inouts.cpp
199c441239762eec86b3cb4b558aef486907a8b6 06-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Fix inlining with sampler array or struct dereferences as arguments.

Previously, we'd replace an argument of mysampler[2] with a plain
reference to mysampler by using the cloning hash table. Instead, use
a visitor to clone whatever complicated sampler dereference into the
sampler parameter derefs in the inlined function body.
r_function_inlining.cpp
8d61a23b1a1d0d4b21f0fab64f6d863a8ee3d7f1 06-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Don't assert in a couple of places when encountering sampler arrays.

Fixes glean shaderAPI.
inker.cpp
4f397e1d641bf265b395f7dec062dab451fb5a54 06-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Enable all supported extensions in stand-alone compiler
lsl_parser_extras.cpp
0a09d679ca97dcb634a939df2110a90c9504e2ec 06-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Don't have two versions of a type with the same name

Previously some sampler types were duplicated in GLSL 1.30 and
GL_EXT_texture_array. This resulted in not being able to find the
built-in sampler functions when the extension was used. When the
built-in functions were compiled, they bound to the 1.30 version.
This caused a type mismatch when trying to find the function. It also
resulted in a confusing error message:

0:0(0): error: no matching function for call to `texture2DArray(sampler2DArray, vec3)'
0:0(0): error: candidates are: vec4 texture2DArray(sampler2DArray, vec3)

0:0(0): error: vec4 texture2DArray(sampler2DArray, vec3, float)
uiltin_types.h
lsl_types.cpp
1e0f0459e0ca8b9f0c67f8178e5189b8cfd6078c 06-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Log a better error message when a matching function cannot be found
st_function.cpp
bc4034b243975089c06c4415d4e26edaaaec7a46 06-Aug-2010 Eric Anholt <eric@anholt.net> 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
akefile
r.h
r_explog_to_explog2.cpp
r_optimization.h
r_validate.cpp
inker.cpp
8048226b7b1bbe8fd89f9c32fa4fadca4b8760c4 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Insert global declarations at the top of the instruction stream.

Fixes use-before-decl in glslparsertest shaders.

Fixes:
CorrectFull.frag
CorrectModule.frag
st_to_hir.cpp
0a0ab121f87a3b00e29c20a38fdd28e2fc31bae7 05-Aug-2010 Eric Anholt <eric@anholt.net> ir_structure_splitting: Massive fixing to this.

I'd missed putting in the actual "find structures to split" part, so
most of the code didn't do anything. I was running on too large of an
app and assuming the lack of progress was elsewhere.
r_structure_splitting.cpp
748f81a8eacabf07e1d26372a61683e6759a61a3 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Make the HV actually call ir_texture's visit_leave.
r_hv_accept.cpp
7f7eaf0285d011f7cc7e1a63133184a50b24ecaa 05-Aug-2010 Eric Anholt <eric@anholt.net> ir_structure_splitting: New pass to chop structures into their components.

This doesn't do anything if your structure goes through an uninlined
function call or if whole-structure assignment occurs. As such, the
impact is limited, at least until we do some global copy propagation
to reduce whole-structure assignment.
akefile
r_optimization.h
r_structure_splitting.cpp
inker.cpp
c314c8f2310fa0ac51b8953e139f9504e08eb48f 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Fix the dereferences_variable check in ir_tree_grafting.

The HV doesn't descend into ir_variable, which is generally a good
thing (allowing one to distinguish between variable declarations and
refs), but here we never saw tree grafting opportunities killed
because we were looking for the ir_variable child of a dereference to
get visited.

Fixes:
glsl1-function call with inout params
r_tree_grafting.cpp
b259eb28049fc06ebc75a7714834b9ed037a3454 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Don't tree-grafting out assignment to an out variable.

Fixes:
glsl-deadcode-varying.
r_tree_grafting.cpp
9f82806c7b5109553cf806a5652e6b6198665094 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Don't dead-code eliminate a call where the return value is unused.

This showed up since the disabling of inlining at compile time, which
I apparently didn't regenerate piglit summary for.

Fixes:
glsl-deadcode-call.
r.h
r_basic_block.cpp
r_dead_code.cpp
r_dead_code_local.cpp
3bd7e70bf7c4a9a52b425284c9f23689f00de93c 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add some easy-to-enable debug printfs to ir_dead_code.cpp.
r_dead_code.cpp
2e853ca23c8670246dd4efcee0706f68097652f7 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass for removing unused functions.

For a shader involving many small functions, this avoids running
optimization across all of them after they've been inlined
post-linking.

Reduces the runtime of linking and running a fragment shader from Yo
Frankie from 1.6 seconds to 0.9 seconds (-44.9%, +/- 3.3%).
akefile
lsl_symbol_table.h
r.h
r_dead_functions.cpp
r_optimization.h
inker.cpp
c5b9cab49900cbcab78911361976a3678d49e853 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Catch pointless copies in copy propagation.

We wouldn't want to go rewriting dereferences to variables to point at
the same variable it did before. While I didn't find a way to trigger
that, a shader in Yo Frankie managed to produce a self-assignment by
passing a constant to a function doing self assignment like this.

Cleans up the IR for glsl-deadcode-self-assign.shader_test
r_copy_propagation.cpp
f4239872c9cb56d1e5735b62ea53bedf3f39dfb0 05-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Ignore #if and #elif expressions when skipping.

Fixes glcpp test cases 073 and 074, as well as piglit test
xonotic-vs-generic-diffuse.vert.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
d65135a7661c320c618151df0a94c852dc9bc621 05-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp/tests: Add a corollary to testcase 073 for testing #elif.
lcpp/tests/074-elif-undef.c
c52b2be16689fbbe8a8ec190dbe9dc7e469956a0 05-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp/tests: Fix 073-if-in-ifdef.c to use #ifdef, not #if.

The original intention was to use #ifdef.
lcpp/tests/073-if-in-ifdef.c
16b4eed59a07f5e07587f4f9b0cdc304a08a685c 05-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
046bef235744e891e4a48076e1a3ff9a61a63092 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Remove the shader_in/shader_out tracking separate from var->mode.

I introduced this for ir_dead_code to distinguish function parameter
outvals from varying outputs. Only, since ast_to_hir's
current_function is unset when setting up function parameters (they're
needed for making the function signature in the first place), all
function parameter outvals were marked as shader outputs anyway. This
meant that an inlined function's cloned outval was marked as a shader
output and couldn't be dead-code eliminated. Instead, since
ir_dead_code doesn't even look at function parameters, just use
var->mode.

The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from
725 instructions to 636.
st_to_hir.cpp
r.cpp
r.h
r_clone.cpp
r_dead_code.cpp
r_variable.cpp
inker.cpp
a08f27940ac72538ce0b264917207111d629f097 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Remove a dead cut and paste member from ir_variable_refcount_visitor.
r_variable_refcount.h
e3a90b8e38b1d0de9f473caca96779e215071315 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Use linked ir_constant_variable after linking, instead of unlinked.
inker.cpp
022f79e49648d465d2db0240554f58ac42754584 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Return progress from ir_vec_index_to_swizzle.
r_vec_index_to_swizzle.cpp
83cb310dbb47357c4b3065ca0d6739796d9e371f 05-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Generate masked assignments in some expanded matrix operations
r_mat_op_to_vec.cpp
3d58be6135e71e6105ae65850f2dbeaf9ecff5c3 04-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Generate masked assignments in vector and matrix constructors

Previously the in-line matrix and vector constructors would generate
swizzles in the LHS. The code is actually more clear if it just
generates the masked assignments instead of relying on the
ir_assignment constructor to convert the swizzles to write masks.
st_function.cpp
6235c6a83855fe2818affda3c82e1a245bd0232e 05-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Additional validation of write masks
r_validate.cpp
5a7758efbe14dee026245a4f4f4fb3ccf7b2c23b 03-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add ir_assignment::write_mask and associated methods

Replace swizzles on the LHS with additional swizzles on the RHS and a
write mask in the assignment instruction. As part of this add
ir_assignment::set_lhs. Ideally we'd make ir_assignment::lhs private
to prevent erroneous writes, but that would require a lot of code
butchery at this point.

Add ir_assignment constructor that takes an explicit write mask. This
is required for ir_assignment::clone, but it can also be used in other
places. Without this, ir_assignment clones lose their write masks,
and incorrect IR is generated in optimization passes.

Add ir_assignment::whole_variable_written method. This method gets
the variable on the LHS if the whole variable is written or NULL
otherwise. This is different from
ir->lhs->whole_variable_referenced() because the latter has no
knowledge of the write mask stored in the ir_assignment.

Gut all code from ir_to_mesa that handled swizzles on the LHS of
assignments. There is probably some other refactoring that could be
done here, but that can be left for another day.
r.cpp
r.h
r_clone.cpp
r_constant_variable.cpp
r_copy_propagation.cpp
r_dead_code_local.cpp
r_print_visitor.cpp
r_tree_grafting.cpp
r_vec_index_to_swizzle.cpp
8e9ce2eb56a087c2544112700ae1abe3f96648dd 04-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Don't try to construct an ir_assignment with an invalid LHS
st_to_hir.cpp
8dbdcb0b43c8749018ff62dd5751190e54fe2445 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Constant fold the children of many more ir_instruction types.
r_constant_folding.cpp
6ecf62f673bf90d0969f8db032781b49a988975a 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Return a real progress value from constant folding.
r_constant_folding.cpp
3d23f0a90c982ad43a6f18ef69a23b2fcdb1d1d2 05-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Refactor constant folding of rvalues to a function.
r_constant_folding.cpp
0ef79a5f115659b3719a330d01a365e8ca8144c4 04-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Refresh autogenerated lexer and parser.
lcpp/glcpp-lex.c
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
1ffc1cd86186ae5d03bb28a1e041c4a57761515e 04-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove xtalloc wrappers in favor of plain talloc.

Calling exit() on a memory failure probably made sense for the
standalone preprocessor, but doesn't seem too appealing as part of
the GL library. Also, we don't use it in the main compiler.
akefile
lcpp/Makefile.am
lcpp/glcpp-lex.l
lcpp/glcpp-parse.y
lcpp/glcpp.h
lcpp/xtalloc.c
ad98aa9d93646600cc95b3e45a40eec26f18988a 04-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Remove uses of deprecated TALLOC_CTX type.
st_function.cpp
lsl_types.cpp
lsl_types.h
ea3a9eb53a3c9ed99998ead645e2b2e6a3261626 04-Aug-2010 Aras Pranckevicius <aras@unity3d.com> glsl2: add gl_LightModel built-in uniform.
uiltin_variables.h
b6ceddc371d026dc30f2cc0f377bc0214e11d768 04-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Don't try to assign locations for samplers during linking.

Mesa will do the mapping at _mesa_add_sampler() time. Fixes assertion
failures in debug builds, which might have caught real problems with
multiple samplers linked in a row.
inker.cpp
952d0f88e1741d51b641be75f7c5a6565e245a69 04-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Skip talloc_parent in constant_expression of non-constant arrays.
r_constant_expression.cpp
8273bd46877e2ea2b8a02b87a11c68102d07e1f2 04-Aug-2010 Eric Anholt <eric@anholt.net> 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.
st_to_hir.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_function_inlining.cpp
r_import_prototypes.cpp
r_vec_index_to_cond_assign.cpp
ink_functions.cpp
inker.cpp
84ee01f40acf88185484df386b7715034e7685c9 04-Aug-2010 Aras Pranckevicius <aras@unity3d.com> glsl2: Set ir_discard::ir_type when cloning it

Fixes unset ir_type after inlining.
r.h
c22dee721695402d9f2678c100d2fff5c0c3f21f 03-Aug-2010 Eric Anholt <eric@anholt.net> 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
r_validate.cpp
900ab2f564018856133c19b68713a6dfd206c184 03-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: No need to strdup the name passed in to ir_variable constructor.

ir_variable always strdups the incoming name so that it matches the
lifetime of the ir_variable.
st_function.cpp
c8babd5d9bba75c9f38f384f9cb3587e3543cc28 03-Aug-2010 Eric Anholt <eric@anholt.net> 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.
r_constant_expression.cpp
5704ed27dd2ebc88639cbd32ac971939ef3c267a 03-Aug-2010 Eric Anholt <eric@anholt.net> 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.
r_constant_expression.cpp
1575070bfeedbc7decb7e44ac81abaeec0497a07 03-Aug-2010 Carl Worth <cworth@cworth.org> glsl2: Use talloc_zero_size instead of talloc_size to allocate ast_node objects.

This is a zero-ing function, (like calloc), to avoid bugs due to
accessing uninitialized values. Thanks to valgrind for noticing the
use of uninitialized values.
st.h
42f3e7b6d7b42218feafe85a2328d8ce86fcce93 02-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Use string key for array type hash
lsl_types.cpp
lsl_types.h
7ffe40532f6b22d9b80caeac0fc3b9495619186a 02-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Clean-up two 'unused variable' warnings
r_validate.cpp
ain.cpp
cf41c8a0d8dac52bafb7c3e85171566c492786ab 02-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Make glsl_types::ctx private again
lsl_types.cpp
lsl_types.h
eb7e120f0f342541716882c211eca115c2cd0d21 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Fix expression type in builtin tan().

Fixes glsl-fs-tan-1.
uiltin_function.cpp
uiltins/110/tan
ee7666b5ac2fc7de64baf60835271e15baf89474 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add validation that talloc ownership of ir_* names is right.
r_validate.cpp
e75dbf66d011d76b6944dc4ee55e339ee285510c 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Fix validation for ir_unop_not.

We use vector ir_unop_not to implement builtin not(), and that seems fine.
r_validate.cpp
47f3f223119739efd337ce1757c2e00d61be34cb 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Add support for floating constants like "1f".

Fixes glsl-floating-constant-120.
lsl_lexer.cpp
lsl_lexer.lpp
960ba0014af7009f8543c55f455271cf3cb45cd6 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Initialize the ARB_fcc fields of ir_variable.

Fixes intermittent failure in glsl-arb-fragment-coord-conventions.
r.cpp
b8db38e1c4f639cb0a063250d43f5a0ef6afd50f 02-Aug-2010 Eric Anholt <eric@anholt.net> 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.
st.h
004e924014f749e8ae5cc7a40e1bb431af0b9041 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Fix spelling of "precision" in error output.
lsl_parser.cpp
lsl_parser.ypp
f311d8e9e9ef79fde762fbd7817f7fe51b37dc45 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Don't add mesa/program/ as an include dir. Let includes say program/.
akefile
31747155ea3a24190277b125bd188ac8689af719 28-Jul-2010 Aras Pranckevicius <aras@unity3d.com> glsl2: Give the path within src/mesa/ for headers instead of relying on -I.
st_type.cpp
lcpp/glcpp.h
lsl_types.cpp
ir_field_selection.cpp
r_clone.cpp
r_function_inlining.cpp
r_validate.cpp
ink_functions.cpp
inker.cpp
b35703df107b50b2c3f5cd4d56790921e8106324 02-Aug-2010 Aras Pranckevicius <aras@unity3d.com> 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.
st.h
6a41626e90f75318e17d9907f4f57a8c3c315fea 02-Aug-2010 Eric Anholt <eric@anholt.net> glsl2: Make non-square matrix keywords not keywords pre-120.

Fixes glsl-mat-110.
lsl_lexer.cpp
lsl_lexer.lpp
93b10bd353e98670b627873e1da130c789646a4e 01-Aug-2010 Eric Anholt <eric@anholt.net> glcpp: Add a testcase for the failure in compiling xonotic's shader.

gcc and mesa master agree that this is OK.
lcpp/tests/073-if-in-ifdef.c
lcpp/tests/073-if-in-ifdef.c.expected
f6b03f323500c71fc20c0d64c618d9aa73ced5b4 01-Aug-2010 Eric Anholt <eric@anholt.net> 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.
inker.cpp
784695442c415cf0be882434a25671ecfb635d34 31-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add new tree grafting optimization pass.
akefile
r_optimization.h
r_tree_grafting.cpp
inker.cpp
ain.cpp
d72edc4dddb6dd7908ef0d3f2cec353b028bf6c5 31-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Factor out the variable refcounting part of ir_dead_code.cpp.
akefile
r_dead_code.cpp
r_variable_refcount.cpp
r_variable_refcount.h
1c325af4d6b907e0a47ab7f868a2a78f054f153f 29-Jul-2010 Aras Pranckevicius <aras@unity3d.com> glsl2: Fix stack smash when ternary selection is used.
st_to_hir.cpp
3fa1b85196b7d57c6c139e62000ac519b1b2320c 30-Jul-2010 Eric Anholt <eric@anholt.net> 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
uiltin_function.cpp
uiltins/110/atan
ec9675ec533cc0c0c7b1c738280e9b9adf2591fb 30-Jul-2010 Carl Worth <cworth@cworth.org> 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!
lsl_parser_extras.cpp
5e5583ee06cff53db48151c13b21916a166ea2ed 30-Jul-2010 Eric Anholt <eric@anholt.net> 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.
ink_functions.cpp
939a1807fe5a70db25725335ba0acccce8b01db3 30-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Initialize ir_function_signature::is_built_in.

Fixes a valgrind error.
r.cpp
805cbf39224580fdb85b09a21be7cbc658f0ecf6 30-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Don't look for backslashes before the beginning of the string.

Fixes a valgrind error.
lcpp/pp.c
0cf545ec696ab450c3f5ee65d7a0c2a5d9dca409 30-Jul-2010 Eric Anholt <eric@anholt.net> 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
r_if_return.cpp
a62ef12ef242ecd48887df2aa2052d2ecb0979f7 29-Jul-2010 Eric Anholt <eric@anholt.net> 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)
r_if_return.cpp
18964618a14996fff7ab5a5db75c85cd64865ef4 29-Jul-2010 Eric Anholt <eric@anholt.net> 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)
r_if_return.cpp
92a3768cef122c699b0121ab168def6eaa0faa7a 29-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Refactor a bit of ir_if_return for the next changes.
r_if_return.cpp
0e1992255837c88ba3c6631d5282fe944703ba56 30-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Allow use of _mesa_print_ir without a parse state on hand.
r_print_visitor.cpp
ee4b4bab682ca64740b78d99d421e3d676eec447 29-Jul-2010 Eric Anholt <eric@anholt.net> 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)
r_constant_variable.cpp
bf496862be1ba863285aa2c1a2262b2d764c3e53 29-Jul-2010 Eric Anholt <eric@anholt.net> 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.
r_print_visitor.cpp
r_print_visitor.h
9a8eb684d4cd602b6c5e6876cd1eceabc3a8896c 29-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: When dumping IR for debug, skip all the empty builtin prototypes.
r_print_visitor.cpp
62c4763b707e2227409f81b09dd5cf6e4410ea6a 29-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix spelling of "sentinel."
st_function.cpp
r.cpp
r_clone.cpp
r_function.cpp
r_function_inlining.cpp
inker.cpp
ist.h
fa33d0b85403da94e3f4a7e6c868af215c076b4b 29-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix spelling of "initializer."
st_to_hir.cpp
4285247f12d45b0505da06773d7cafcd2c296fb5 29-Jul-2010 Eric Anholt <eric@anholt.net> 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.
r_function_inlining.cpp
d6942460cec5ffb69dfee7492f7dac59872735de 29-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Actually fix glsl-version-define.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
d4a04f315560704bf1103df0b93723e468725df7 29-Jul-2010 Eric Anholt <eric@anholt.net> glcpp: Add __VERSION__ define to the current language version.

Fixes:
glsl-version-define
glsl-version-define-110
glsl-version-define-120
lcpp/glcpp-lex.c
lcpp/glcpp-lex.l
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
lcpp/glcpp-parse.y
8605c297cfb8068737991601f163f866395c41c9 29-Jul-2010 Eric Anholt <eric@anholt.net> glcpp: Print integer tokens as decimal, not hex.
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
192b57df8c451c7ae39e5471124a9bab36ec17f8 29-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Make lowp, mediump, highp, and precision identifiers pre-1.20.

Fixes glsl-precision-110.
lsl_lexer.cpp
lsl_lexer.lpp
35cc8b98ec4d898417de5b820dcbcf62c74b3599 29-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> 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.
akefile
56af4e56e3852363a810174c64650df6f0ae4f53 28-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Fix outerProduct builtin.

The type signatures were completely backwards.
uiltin_function.cpp
uiltins/120/outerProduct
uiltins/tools/generate_outerProductGLSL.py
7ddee6a535f7323d7c6131e52e7933130d886ae4 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "outerProduct" builtin.
r_constant_expression.cpp
5d255e24b29930e78321c1ba807df71fea12174a 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "mix" builtin.

Both 1.10 and 1.30 variants.
r_constant_expression.cpp
b09ae5dd3f9b8e380e2608f4ee3a7902f5ecc15e 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "transpose" builtin.
r_constant_expression.cpp
546f3a27540c408c9d83368c5f6144e13167dcb3 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "smoothstep" builtin.
r_constant_expression.cpp
a4ca1cfb66160c4ea2325f503ff025a4adc35084 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "clamp" builtin.
r_constant_expression.cpp
ff58b7c9b6f513ed8bf57b3e4283b67b06fd9d34 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "step" builtin.
r_constant_expression.cpp
3d5c2f0adbd72a68d4fe3900b0d3e267510950ef 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "faceforward" builtin.
r_constant_expression.cpp
04b3643dbf2e0d25e67c86845b2506ad1d26939d 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "refract" builtin.
r_constant_expression.cpp
d60b2b03da30093ae85458f1d0be3cc5c33d992c 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "reflect" builtin.
r_constant_expression.cpp
53f306d573ce6393062cf86d4fe31148eacc5e1e 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "normalize" builtin.
r_constant_expression.cpp
8fe5f30645e1b6a87497c1abc408ade633e9ebc1 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "matrixCompMult" builtin.
r_constant_expression.cpp
a7650af706b359056db8b9da6d1d83669106d463 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> 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.
r_constant_expression.cpp
5489ad086f77e548905c98ccd27cd626d706d5f9 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "length" builtin.
r_constant_expression.cpp
ffcec135997545b4dc2b3393ccb02558083373a0 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Extract dot product calculation for reuse.
r_constant_expression.cpp
4b1d77ea966771dc5fbdac90dfec1b6066afe3f8 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> 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.
r_constant_expression.cpp
557827340aedbf64d2486226924d00c94107c9e8 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "greaterThanEqual" builtin.
r_constant_expression.cpp
7f042b98126b1710c819091512621c642f8fcbbc 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "greaterThan" builtin.
r_constant_expression.cpp
319f4949e0a5f1daa3a760fc84096c041e3ce815 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "lessThanEqual" builtin.
r_constant_expression.cpp
6d897f07cf7ed8492ef5f0da90259856fdac5bf6 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "lessThan" builtin.
r_constant_expression.cpp
48a69ba05794f3d253114b452174710a15eefadf 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "notEqual" builtin.
r_constant_expression.cpp
0b6ef6ef6e1930b6ec03dae7ace53372bb239981 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "equal" builtin.
r_constant_expression.cpp
2eaf31642c83086b06dce057997ae4bc4b1bce2c 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "distance" builtin.
r_constant_expression.cpp
7bcaa3828f8d3d39cfece5d91e47ed2a135a9471 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "degrees" builtin.
r_constant_expression.cpp
0afe3493221c6a676bcc045aca508bb08f58a4f4 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "radians" builtin.
r_constant_expression.cpp
20970f7dea220a2f44c180579630f453729ab31b 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "tanh" builtin.
r_constant_expression.cpp
9c9f8b2d69094fb308de0d6a28bcd60cdf8aedf6 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "tan" builtin.
r_constant_expression.cpp
5d551daf38e30d6cb863038afe1a8e32c806e6ae 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "sinh" builtin.
r_constant_expression.cpp
ba4178345a1eb8e697a8cb01b5594c0a3b4b1d29 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for the "cosh" builtin.
r_constant_expression.cpp
13f8758e9c3babdee3fc0b8b8e1d4a7e13ef9694 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for "atan" builtins.
r_constant_expression.cpp
f6ea9dfe473ccb0b5121461653696fe07ee4f328 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for "acos" builtin.
r_constant_expression.cpp
3b6c29b8f00a2475b24022cace69f372b470a9b1 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for "asin" builtin.
r_constant_expression.cpp
d6792a7f7c2b73486987d2bc07fc77d46456b65d 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for "any" builtin.
r_constant_expression.cpp
aca7e95222ac33e5eda84ecc566da609f6f6ce8e 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for "all" builtin.
r_constant_expression.cpp
8b1680acc38cfbb6d2fc80ddab3f3eed24e2522a 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Implement builtins that wrap an expression.

These builtin functions are represented by ir_expression_operations, so
we can just create one of those and ask for its value.
r_constant_expression.cpp
38cb1b273f55f98349d981445cfe06351322b032 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for builtins dFdx, dFdy, and fwidth.

These always return zero (the derivative of a constant).
r_constant_expression.cpp
46d91615a2f6e1beaee98f40af957ba1a1a6b349 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Set constant_value on return value temporaries in 1.20+.
st_function.cpp
bafd89fa0f026cef12024382b154a41d90d00373 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Stub out support for constant builtins.
r_constant_expression.cpp
f914915d8e86f492cfcbbf834df601251bbba033 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Use Mesa's MIN2/MAX2 instead of our own.
r_constant_expression.cpp
f7b94f32a22a769fc71065ca6515186e5a8e3a96 28-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_algebraic: Use ir_constant::zero.
r_algebraic.cpp
ee9a3a51b61f0afe75b4b8b0c3025310140437ec 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add new ir_constant::zero static method.

This conveniently creates a zero value of whatever type you want.
r.cpp
r.h
0c7b37c8367e72e7b4295cd249561e5c3079d161 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add the define for ARB_fragment_coord_conventions when present.

Fixes:
glsl-arb-fragment-coord-conventions-define
lcpp/glcpp-parse.c
lcpp/glcpp-parse.y
4a962170d7cf4243d6ae156fca20a6167388925d 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.

Fixes:
glsl-arb-fragment-coord-conventions
st_to_hir.cpp
r.h
r_clone.cpp
8d8469eb2ade4fd48188403351a38f740987fb80 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Perform some semantic checking of ARB_fcc layout qualifiers

The rest cannot be handled until built-in variables (i.e.,
gl_FragCoord) can be redeclared to add qualifiers.
st_to_hir.cpp
f50f06552eb1e4af27d6fe99c381eac6a0a4ea0f 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Parser support for GL_ARB_fragment_coord_conventions
st.h
lsl_lexer.cpp
lsl_lexer.lpp
lsl_parser.cpp
lsl_parser.h
lsl_parser.ypp
lsl_parser_extras.cpp
lsl_parser_extras.h
b706283c79de41caf775b0bb15b3c849932f2574 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fail linking where the FS reads a varying that the VS doesn't write.

Fixes:
glsl1-varying read but not written
glsl1-varying var mismatch
inker.cpp
a6c7606ab6e2ba8b4fc253e93a83ca2f18a874b4 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Unmark unwritten varyings as varying.

This fixes an assertion failure in ir_to_mesa, and the varying won't
take up varying space.
inker.cpp
667173e36293d781e145f40e0d6919cb847af318 28-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Add generated source files.

This is now consistent with other usage of flex/bison througout mesa,
(which is that these generated files are added to source control so
that the build system does not require external tools like flex/bison
for non-developers).
lcpp/.gitignore
lcpp/glcpp-lex.c
lcpp/glcpp-parse.c
lcpp/glcpp-parse.h
f8a04b38775cc9f40619e3fb3be39d585e0d4920 28-Jul-2010 Carl Worth <cworth@cworth.org> glsl: Ignore glsl_compiler and glsl_parser.output files.

These are generated files where we can do the sane thing, and keep
them out of version control.
gitignore
e8a8f0f278d3c2b46b9e9883cbd837a59fcc3aaa 28-Jul-2010 Carl Worth <cworth@cworth.org> glsl: Add generated files from flex/bison.

The mesa build environment does not (currently) accept external
dependencies such as flex and bison. The compromise is to commit the
generated output files, (in spite of the pain that comes from having
generated files under version control).
lsl_lexer.cpp
lsl_parser.cpp
lsl_parser.h
279cc22dbc297b32ddc7301ed1790336cd1038ae 28-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Add expected output for a recently-added test.

I simply forgot to add this file when adding the test case originally.
lcpp/tests/069-repeated-argument.c.expected
85b5dba5933437763dfb6ddc5384f59c0943d658 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add the remaining builtin uniforms.
r_variable.cpp
73df636e043fc72a07b0b8b759906d92d7edf793 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Size builtin arrays according to the context constants.

Cleans up some of the FINISHMEs in this file.
r_variable.cpp
efef950f393dfe6cb7ef60bee646f2197143df41 28-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Explicitly expect 0 shift/reduce conflicts.

The "%expect 0" construct will make bison emit an error if any future
changes to the grammar introduce shift/reduce conflicts, (without also
increasing the number after "%expect").
lcpp/glcpp-parse.y
2233d10442f1e19d18693fc030aefe292b14cf29 28-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Remove 2 shift/reduce conflicts from the grammar.

Since we have productions to turn "defined FOO" and "defined ( FOO )"
into a conditional_token we don't need to list DEFINED as an operator
as well. Doing so just introduces the shift/reduce ambiguity with no
benefit.
lcpp/glcpp-parse.y
f9b0e5e322a676cf778dc3785281040fcc0bd248 28-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: When stealing var->constant_value, steal its children as well.

Fixes:
glsl1-GLSL 1.20 uniform array constructor
r.cpp
59c45e9e6cf80be149c6e5d94763e98312f49be2 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Actually use the linked dead code eliminator.

I managed to revert the change from unlinked at some point while
cleaning up the changes. glsl-fs-raytrace-bug27060 drops from 389
instructions to 370.
inker.cpp
54f583a206a15b1a92c547333adfae29ced796ef 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Don't dereference a NULL var in CE handling during a compile error.

If an undeclared variable was dereferenced in an expression that
needed constant expression handling, we would walk off a null ir->var
pointer.

Fixes:
glsl1-TIntermediate::addUnaryMath
r_constant_expression.cpp
bf6ad0ab3d3940ca642c388444f7ddae91eefffc 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Use ir_dead_code's linked version after linking.

glsl-fs-raytrace-bug27060 goes from 485 Mesa IR instructions to 389
before Mesa IR optimization.
inker.cpp
5532c4ca696fea32fb9b2f8de15beabe4a20ae15 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix the linked version of ir_dead_code.

If we don't walk into functions, we won't see any usage of variables
in the functions.
r_dead_code.cpp
66d4c65ee2c311ea0c71c39a28456d0c11798d6b 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Make the dead code handler make its own talloc context.

This way, we don't need to pass in a parse state, and the context
doesn't grow with the number of passes through optimization.
r_dead_code.cpp
r_optimization.h
ain.cpp
85cd64ee170e578317a6aa41d824314550a318ac 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Talloc type names.

Otherwise, we end up losing structure names after compile time, and
dumping IR often ends up reporting some other mysterious string.
lsl_types.cpp
lsl_types.h
832aad989e3d319a8aaac046aa49df25da134d82 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add optimization pass for algebraic simplifications.

This cleans up the assembly output of almost all the non-logic tests
glsl-algebraic-*. glsl-algebraic-pow-two needs love (basically,
flattening to a temporary and squaring it).
akefile
r.h
r_algebraic.cpp
r_optimization.h
ain.cpp
5533c6e38030ff6e26375a1a4e4bfa9ab2204d4c 27-Jul-2010 Eric Anholt <eric@anholt.net> ir_validate: Check the types of expression operations.
r_validate.cpp
6a1401eb889b5e535c212c414743cc7ea07f6622 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix missing visit_continue return in ir_validate.
r_validate.cpp
fbaca31352678ab7d7bf132f0c9a6aa29ca9fabf 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Also steal the constant components of aggregate-typed ir_constants.
r.cpp
eb2cc4f1b1f5ac657c632aa41da5f23eb1cdbe10 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Steal ir_variable's constant_value field.

Fixes a link-time crash in glsl-vs-cross-3.
r.cpp
e2130d4e39b6ebd9f5d39598a006906680efd830 27-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Remove old .gitignore file from when we were out of tree.
gitignore
afe125e0a18ac3886c45c7e6b02b122fb2d327b5 27-Jul-2010 Eric Anholt <eric@anholt.net> Merge remote branch 'origin/master' into glsl2

This pulls in multiple i965 driver fixes which will help ensure better
testing coverage during development, and also gets past the conflicts
of the src/mesa/shader -> src/mesa/program move.

Conflicts:
src/mesa/Makefile
src/mesa/main/shaderapi.c
src/mesa/main/shaderobj.h
3e882ec84a2493da74c55d105010a37de521e593 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Fix broken code for floating point modulus.

It's supposed to be x - y * floor(x/y), not (x - y) * floor(x/y).
r_constant_expression.cpp
0a71527dabb7086e81d488451cf4a5cd90380938 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
0b8e5f384c75b56bf2ee34c317bb9d06095c798b 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Add 1.30 bvec variant of the "mix" builtin.
uiltins/130/mix
5304c251fcceca40096d69002efcf1a122df259d 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Fix 1.30 sign implementation for ints.
uiltins/130/sign
63a92c975dd97445979c6aa1c5fef63d37bfc897 22-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Fix "mod" builtin to use scalar/vector operations.
uiltins/110/mod
0a89175a35ba3ac2a94d0ba9bcc9926edc8927e3 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Initialize ir_instruction::type and ir_rvalue::type.

Top-level instructions now get NULL as their default type (since type is
irrelevant for things like ir_function), while ir_rvalues get error_type
by default.

This should make it easier to tell if we've forgotten to set a type. It
also fixes some "Conditional jump or move depends on uninitialized
value" errors in valgrind caused by ir_validate examining the type of
top level ir_instructions, which weren't set.
r.cpp
r.h
3c033637de7def553559c11d037f2e8bbb750f77 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Make ir_assignment derive from ir_instruction, not ir_rvalue.

Assignments can only exist at the top level instruction stream; the
residual value is handled by assigning the value to a temporary and
returning an ir_dereference_variable of that temporary.
r.h
r_reader.cpp
aa9f86ae8b3bb2172092ff9b50751677c509e6b4 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Fix standalone compiler to not crash horribly.

ir_to_mesa was updated for the _mesa_glsl_parse_state constructor
changes, but main.cpp was not.
lsl_parser_extras.cpp
ain.cpp
40c4298a6ea9e83b49858916d5423fd2135ef39c 23-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_print_visitor: Add "temporary" to mode string printing.

Variables with mode ir_var_temporary were causing an out of bounds array
access and filling my screen with rubbish. I'm not sure if "temporary"
is the right thing to print.
r_print_visitor.cpp
fbe4240626bfe102a9c4c889ee18cb9ea27bddec 23-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Fix function-like macros with an argument used multiple times.

It's really hard to believe that this case has been broken, but apparently
no test previously exercised it. So this commit adds such a test and fixes
it by making a copy of the argument token-list before expanding it.

This fix causes the following glean tests to now pass:

glsl1-Preprocessor test 6 (#if 0, #define macro)
glsl1-Preprocessor test 7 (multi-line #define)
lcpp/glcpp-parse.y
lcpp/tests/069-repeated-argument.c
a0879b9dd438d78635f047cdd5ed4c72bc831b60 23-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Put side effects of the RHS of logic_or in the right branch.

Kind of missing the point to only do the side effects if the LHS
evaluates as true.

Fixes:
glsl1-|| operator, short-circuit
st_to_hir.cpp
432b787b29202301dbfc139c3289521b0bfc3dec 23-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Validate that ir_if conditions are actually bool.
r_validate.cpp
9703ed05e684f4269cd8af27c94e9b6bf8781d85 23-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: When setting the size of an unsized array, set its deref's size too.
st_to_hir.cpp
c3081e627302429cdf2ee23a40fb20fa5cbf5770 23-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Set the type on cloned tex instructions.
r_clone.cpp
a711ad6bf2407f63110de8e8f216eacd09dd8e82 23-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add the API defines to the glsl2 build so we get the right GLcontext

Fixes:
draw_buffers-08.frag
draw_buffers-09.frag
glsl-vs-texturematrix-2
akefile
1bef4c8c4bc11e7f4150500def6e6a4291ceb587 22-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix builtin prototypes defined in multiple glsl/builtins/* files

If we put the protos in separate ir_functions, they wouldn't be found
at lookup time for linking.

Fixes:
glsl-fs-texture2d-bias
glsl-fs-texture2dproj-bias
glsl-fs-texture2dproj-bias-2
glsl-lod-bias
glsl1-texture2D(), computed coordinate
r_import_prototypes.cpp
47c90b144729e3edf3b5cbf5b260c1c46e429879 22-Jul-2010 Carl Worth <cworth@cworth.org> glsl2: Fix expected type for multiplying vector with non-square matrix.

Previously, the compiler expected the result of the multiplication to
be of the same type as the vector. This is correct for square
matrices, but wrong for all others.

We fix this by instead expecting a vector with the same number of rows
as the matrix (for the case of M*v with a column vector) or the same
number of columns as the matrix (for v*M with a row vector).

This fix causes the following four glean tests to now pass:

glsl1-mat4x2 * vec4
glsl1-vec2 * mat4x2 multiply
glsl1-vec3 * mat4x3 multiply
glsl1-vec4 * mat3x4 multiply
st_to_hir.cpp
e65dfa89eef86be127d788ecd5bd23c35c8fbbe4 22-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix the type of (1.0 - arg2) for mix(gen, gen, float).

Previously, we'd constant-fold up a value of vec4(1.0 - arg2, 0, 0, 0).

Fixes:
glsl1-mix(vec4) function
uiltin_function.cpp
uiltins/110/mix
8ec0b8187ea695353c75eed7314e86344df60e5a 22-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: When inlining, don't clone and assign sampler arguments.

Instead, just use the incoming sampler param. Fixes many texture-using
piglit tests since the linker rework.
r_function_inlining.cpp
2d1ed7b1b112cf13dd7eda7f500691f4c98a1ccc 22-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: When a "continue" happens in a "for" loop, run the loop expression.

Fixes:
glsl1-for-loop with continue

Bug #29097
st_to_hir.cpp
lsl_parser_extras.h
e9384d1d7fdf06b6345b3be0a70a294b90eac96e 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Update TODO.
ODO
9a6d40fbfb679f01412c1fcc9d767c20a22246d8 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for array == and !=.

Piglit parser tests const-array-03.frag and const-array-04.frag now
generate the correct code.
r.cpp
r_constant_expression.cpp
a096fa747611472965cf0f953bfe2757fc80383c 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for constant arrays.

Fixes piglit test const-array-02.frag.
r_constant_expression.cpp
ef2c38b2450eb366a2e6f6a46d1725aa6c14d74b 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Add support for reading constant arrays.
r_reader.cpp
9930d18c2aefad12152d12bc251d02ae1c1593bc 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_print_visitor: Print out constant arrays.
r_print_visitor.cpp
7ea977a15c05f4a638478b7a5b8ca78454cecf41 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_print_visitor: Remove commas between ir_constant's components.

The IR reader does not expect commas.
r_print_visitor.cpp
74e1802f5dd8921750851abc6128e4073602d405 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Extend ir_constant to store constant arrays, and generate them.

Since GLSL permits arrays of structures, we need to store each element
as an ir_constant*, not just ir_constant_data.

Fixes parser tests const-array-01.frag, const-array-03.frag,
const-array-04.frag, const-array-05.frag, though 03 and 04 generate the
wrong code.
st_function.cpp
r.cpp
r.h
r_clone.cpp
13a19745d46d383fa7fc148ce129150ebde151b7 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Emit array constructors inline.
st_function.cpp
e1d71850faba23d1bea3858a8c2e05a45fd21143 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ast_to_hir: Fix bug in constant initializers.

Implicit conversions were not being performed, nor was there any
type checking - it was possible to have, say, var->type == float
and var->constant_value->type == int. Later use of the constant
expression would trigger an assertion.

Fixes piglit test const-implicit-conversion.frag.
st_to_hir.cpp
46d6b8d1ba09d9d6844ce99a30416283004f77c6 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_u2f.

Also make ir_unop_i2f only operate on signed integers.
r_constant_expression.cpp
3163f87463e6d0123c4f95bd76a658cb1e5d0843 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Remove open coded equality comparisons.

The ir_constant::has_value method already does this.
r_constant_expression.cpp
0048c7aef82b17c6bd160f49125a91a70cbf2b55 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add some comments.
st_function.cpp
c7a18da69022d3f9b05c21ff2473e8ea390f77f1 20-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Replace insert_before/remove pairs with exec_node::replace_with.
st_function.cpp
r_expression_flattening.cpp
r_function_inlining.cpp
r_if_return.cpp
r_vec_index_to_cond_assign.cpp
r_vec_index_to_swizzle.cpp
d5be2acae379783c4aa31243e0a88a9e67e6ca7e 20-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Link built-in functions instead of including them in every shader

This is an invasive set of changes. Each user shader tracks a set of other
shaders that contain built-in functions. During compilation, function
prototypes are imported from these shaders. During linking, the
shaders are linked with these built-in-function shaders just like with
any other shader.
uiltin_function.cpp
uiltins/110_vs/ftransform
uiltins/tools/generate_builtins.pl
lsl_parser_extras.h
r.h
inker.cpp
ain.cpp
4ccd3c548b9b9a2fee79342445f68d73525bfcdb 20-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add function to import function prototypes from one IR tree to another
akefile
r.h
r_import_prototypes.cpp
a0cfe8c44085032fd982bbbff1f02252ffaa7114 21-Jul-2010 Carl Worth <cworth@cworth.org> glsl: Fix missing initialization of yylloc.source

In both the preprocessor and in the compiler proper, we use a custom
yyltype struct to allow tracking the source-string number in addition
to line and column. However, we were previously relying on bison's
default initialization of the yyltype struct which of course is not
aware of the source field and leaves it uninitialized.

We fix this by defining our own YYLLOC_DEFAULT macro expanding on the
default version (as appears in the bison manual) and adding
initialization of yylloc.source.
lcpp/glcpp.h
lsl_parser_extras.h
c24bcad9f88379ffba9e2f0ff92f22cdf60c2927 21-Jul-2010 Carl Worth <cworth@cworth.org> glsl: Correctly handle unary plus operator.

Previously, any occurence of the unary plus operator would trigger a
bogus type mismatch error. Fix this by making the ast_plus case look
more like the ast_neg case as far as type-checking is concerned.

With this change the shaders/CorrectPreprocess8.frag test in piglit
now passes.
st_to_hir.cpp
f38d15b80d4e4c8ecb7a76087cdc49835f0aa271 21-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: glsl_type has its own talloc context, don't pass one in
st_function.cpp
st_to_hir.cpp
lsl_types.cpp
lsl_types.h
r_reader.cpp
r_variable.cpp
a7ba9a7919110fd619b0e792368aa1f3534080fe 20-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Do post-link lowering and optimization

The lowering code should probably be moved elsewhere.
inker.cpp
60e2d06d1ccc66ad00cd7ab81c418853f21be291 20-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Implement utility routine to talloc reparent an IR tree
r.cpp
r.h
ain.cpp
2462a536ea5c98867296905e3da127eba7c7bdff 19-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add a constructor for _mesa_glsl_parse_state

Coming changes to the handling of built-in functions necessitate this.
akefile
lsl_parser_extras.cpp
lsl_parser_extras.h
7e2aa91507a5883e33473e0a94215ee3985baad1 20-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add and use new variable mode ir_var_temporary

This is quite a large patch because breaking it into smaller pieces
would result in the tree being intermitently broken. The big changes
are:

* Add the ir_var_temporary variable mode

* Change the ir_variable constructor to take the mode as a
parameter and correctly specify the mode for all ir_varables.

* Change the linker to not cross validate ir_var_temporary
variables.

* Change the linker to pull all ir_var_temporary variables from
global scope into 'main'.
st_function.cpp
st_to_hir.cpp
lsl_types.cpp
r.cpp
r.h
r_clone.cpp
r_expression_flattening.cpp
r_function.cpp
r_function_inlining.cpp
r_if_return.cpp
r_if_to_cond_assign.cpp
r_mat_op_to_vec.cpp
r_mod_to_fract.cpp
r_reader.cpp
r_variable.cpp
r_vec_index_to_cond_assign.cpp
inker.cpp
f141fa63a4391621cc92cd2c39724a952b297a58 21-Jul-2010 Eric Anholt <eric@anholt.net> 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.
r_validate.cpp
fade78edcbff1e0ae24a1e2c455be2cc7932ee9c 21-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: strdup the field names used in dereference_record.

Otherwise, after linking and freeing the old data, the pointer would
dangle. Partial fix for glsl1-struct*.
r.cpp
21b0dbd79937e9d6787f045af7d60d4b6c649ec8 21-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: talloc the glsl_struct_field[] we use to look up structure types.

Since the types are singletons across the lifetime of the compiler,
repeatedly compiling a program with the same structure type defined
would drop a copy of the array on the floor per compile.

This is a bit tricky because the static GLSL types are not called with
the talloc-based new, so we have to use the global type context, which
may not be initialized yet.
st_to_hir.cpp
lsl_types.cpp
lsl_types.h
b6e92ad7da9d4f00607caca90bd0b8853623a493 21-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Don't claim a match on structure types with different field names.

We regularly do lookups on the field names of the structure to find
the types within the struct, so returning a structure type with bad
names will lead to lots of error types being found.
lsl_types.cpp
094cf8c199930d958d9e1139467eb8579d082df6 18-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add support for the .length() method on arrays.

Fixes piglit test glsl-array-length, and provides proper error messages
for negative piglit tests array-length-110.frag, array-length-unsized.frag,
and array-length-args.frag.
ir_field_selection.cpp
1036a7ebae2da03efd1b990037b6fd102d4cc5ca 18-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Remove incorrect assertion in the parser.

This assertion is triggered by method calls (i.e. array.length()), where
subexpressions[1] is an ast_function_call expression. Since the
assertion itself had a comment saying it could be removed eventually,
simply do so.

Causes negative glslparser tests array-length-110.frag,
array-length-args.frag, and array-length-unsized.frag to pass, but only
because the length() method is not supported yet.
lsl_parser.ypp
2b7c42b40ae459f7b290eb134d6dabd075aab9f0 17-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Disallow non-constant array indexing for unsized arrays.

Fixes piglit test unsized-array-non-const-index.vert.
st_to_hir.cpp
e4768eecd5da6f9e955aa7c3892810813623f0dc 15-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Remove pointless use of variable_referenced.

ir_dereference_variable always references an ir_variable, so there's no
point in calling a function and NULL-checking the result.
r_constant_expression.cpp
98f32a13bef1eef732304eb8e2781e08835ff69a 15-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Use "this" pointer directly.

In ir_expression's signature, I replaced ir->operands[i] with op[i] as
it is more concise; an assertion already ensures these are equal.
r_constant_expression.cpp
fb2ffd2846b48cb50128fb74df56f2ee63179832 15-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Convert from a visitor to a virtual function.

The constant_expression_wrapper was already the only external API, and
much of the internal code used it anyway. Also, it wouldn't ever visit
non-rvalue ir_instructions, so using a visitor seemed a bit unnecessary.

This uses "ir_foo *ir = this;" lines to avoid code churn. These should
be removed.
r.h
r_constant_expression.cpp
e340854115f2562109c91fa908ffe6628432f989 12-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Move constant_expression_value method to ir_rvalue.

This prevents top-level callers from asking for the value of something
that is guaranteed not to have one.
r.h
r_constant_expression.cpp
e1acbfca322c4ac720707ec8d3fda08fab65a30b 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Avoid accidental token pasting in preprocessed result.

Consider this test case:

#define EMPTY
int foo = 1+EMPTY+4;

The expression should compile as the sequence of tokens 1, PLUS,
UNARY_POSITIVE, 4. But glcpp has been failing for this case since it
results in the string "1++4" which a compiler correctly sees as a
syntax error, (1, POST_INCREMENT, 4).

We fix this by changing any macro with an empty definition to result
in a single SPACE token rather than nothing. This then gives "1+ +4"
which compiles correctly.

This commit does touch up the two existing test cases which already
have empty macros, (to add the space to the expected result).

It also adds a new test case to exercise the above scenario.
lcpp/glcpp-parse.y
lcpp/tests/008-define-empty.c.expected
lcpp/tests/011-define-func-empty.c.expected
lcpp/tests/068-accidental-pasting.c
lcpp/tests/068-accidental-pasting.c.expected
942ccc517012e360a7e30d3322331c8450dda022 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Add missing include in xtalloc.c

Without this, the compiler was legitimately complaining about missing
declarations for all of the functions being defined here.
lcpp/xtalloc.c
d80dcaf427e12a5cba9cfc5bcd1b485572a2714b 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Add static keyword to several functions in the parser.

This quiets warnings about missing declarations otherwise.
lcpp/glcpp-parse.y
fb90560744864e44730330e4c801ac47c4ece0e1 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Avoid warnings in generated flex code.

We define the YY_NO_INPUT macro to avoid one needless function being
generated.

for the other needless functions, (yyunput and yy_top_state), we add a
new UNREACHABLE start condition and call these functions from an
action there. This doesn't change functionality at all, (since we
never enter the UNREACHABLE start condition), but makes the compiler
stop complaining about these two functions being defined but not used.
lcpp/glcpp-lex.l
a9bb4bcde360ef8d0a444bf1c4a7d02a8fdb5fa1 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp-lex: Declare some generated functions to eliminate compiler warnings.

It's really a bug in flex that these functions are generated with neither
a declaration nor the 'static' keyword, but we can at least avoid the
warnings this way.
lcpp/glcpp-lex.l
1d7e03e48e87328ce0081021dde133921b78b406 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Fix support for nested #ifdef and nested #ifndef

Previously, if the outer #ifdef/#ifndef evaluated to false, the inner
directive would not be parsed correctly, (the identifier as the subject
of the #ifdef/#ifndef would inadvertently be skipped along with the other
content correctly being skipped).

We fix this by setting the lexing_if state in each case here.

We also add a new test to the test suite to ensure that this case is tested.
lcpp/glcpp-lex.l
lcpp/tests/067-nested-ifdef-ifndef.c
lcpp/tests/067-nested-ifdef-ifndef.c.expected
17f9beb6c313b41ca08984add7b76ecb84a7339e 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Support #if(expression) with no intervening space.

And add a test case to ensure that this works.
lcpp/glcpp-lex.l
lcpp/tests/066-if-nospace-expression.c
lcpp/tests/066-if-nospace-expression.c.expected
61ebc01dfecda0963a184e881ea966e2d92f0519 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Fix use-after-free error from #undef directive.

By taking advantage of the recently-added hash_table_remove function.

With this change, all existing tests are now valgrind-clean.
lcpp/glcpp-parse.y
d1500f8a195b7afe871cd768a5d33ecfecad5f31 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Make test suite test for valgrind cleanliness.

As it turns out, 4 of our current tests are not valgrind clean,
(use after free errors or so), so this will be helpful for
investigating and fixing those.
lcpp/tests/glcpp-test
3a530b8ef68a40526b33de2af8de85f71ebdb30d 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Make test suite report final count of passed/total tests.

And report PASS or FAIL for each test along the way as well.
lcpp/tests/glcpp-test
41d525f2dfde130b4a1cfa908a729e5a3f79b200 14-Jul-2010 Carl Worth <cworth@cworth.org> Build a standalone glcpp binary.

This is convenient for testing the preprocessor independent of the rest of
mesa, (just run glcpp-test in the src/glsl/glcpp/tests).
akefile
f15e27ec1d3238df5cd5ab40642e21aea5a162e3 14-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Delete copies of hash_table.c, hash_table.h, and other headers.

These were only ever intended to exist in the original, standalone
implementation of glcpp, (with the idea of dropping them as soon as
the code moved into mesa). The current build system wasn't compiling
this C file, but the presence of the header files could cause problems
if the two copies diverge in the future.

We head those problems off by deleting al of these redundant files.
lcpp/Makefile.am
lcpp/hash_table.c
lcpp/hash_table.h
lcpp/main/imports.h
lcpp/main/simple_list.h
325a49701fbee14a99a02c69872a1d7577a633cf 21-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix handling of out values in function inlining.

The parameters[i] is our inlined variables representing the
parameters, so they are always ir_var_auto. Walk the signature params
in handling "out" values like we do for "in" values to find the mode.

Fixes (with the previous 2 commits):
glsl1-function call with in, out params
glsl1-function call with inout params
r_function_inlining.cpp
2927c81ed10c0dc617f734c00376d0582ac3c061 20-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Don't mark a variable as constant if it was used as an out param.
r_constant_variable.cpp
02d3711a21f5766d286b09fbe1eda5d8520d151a 21-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Always insert function calls into the instruction stream.

If they have a return value, this means putting it into a temporary
and making a deref of the temp be the rvalue, since we don't know if
the rvalue will be used or not.
st_function.cpp
f8946699ecfa5bc6566821fb855072bbdbd716b2 20-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add definitions of the builtin constants present in GLSL 1.10.

Fixes:
glsl1-built-in constants
lsl_parser_extras.h
r_variable.cpp
ain.cpp
1245babe0c69846d227a78a11429584433e77a9e 20-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix asin() implementation.

I'd flipped around the order of two operations in paren-balancing
adventures, and left out the multiply by sign(x) required for negative x.

Fixes:
glsl1-acos(vec4) function
glsl1-asin(vec4) function
glsl1-atan(vec4) function
uiltin_function.cpp
uiltins/110/asin
117d154b4d877e8c4d7880432af0a80b8f717dc6 20-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: notEqual() produces a boolean value, not the base type of the args.

Fixes:
glsl1-vector relational (bvec2 ==,!=)
glsl1-vector relational (vec4 !=)
uiltin_function.cpp
uiltins/110/notEqual
14f8e16132409f38656e4874aa53bc471977f9ad 20-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Constant-fold assignment conditions.
r_constant_folding.cpp
5a2e0b8ce59a3d9f8fa7510546137aff40016c74 20-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Don't validate IR if there were compilation errors
ain.cpp
cd6764ed6ec5ae1a4bce636feaf9d4b18ff3ccf3 17-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Remove the FINISHME comment for intrastage linking
inker.cpp
1a03a644d2f933fbbbe535e584a92fdf1ad619f1 17-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Remove redundant check for 'main' in shaders

This is now handled in link_intrastage_shaders.
inker.cpp
25f51d3b9b8c36c41cd23d2797b6a06f6e27ff86 17-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Track and validate GLSL versions used in shaders
inker.cpp
ain.cpp
b64e979971e764ec1df8800d31c755298e618ba0 17-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use Elements macro
uiltin_function.cpp
uiltins/tools/generate_builtins.pl
fc9ae101b4b7a71ca7a5d4f185e887064007e0d1 16-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Recursively resolve function calls in imported functions
ink_functions.cpp
532c2d30850908b75f4b0ad0aa5fa7ce88f8202d 16-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: look up function signatures during linking instead of using callee

Instead of using ir_call::callee, search for the signature in the
linked shader. This will allow resolving calls from functions
imported from other shaders. The ir_call::callee pointer in the
imported function will still reference a signature in the original shader.
ink_functions.cpp
5adbf0bff168c088d9fd5140226b76e3ba6471b8 15-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Pull find_matching_signature out of call_link_visitor

The list of shaders to search needs to be provided as an explicit
parameter to support coming changes. At that point there is no reason
for it to be in the class. Also, fix some of the 'const' decorators.
ink_functions.cpp
b95897b89d36a25c237a021c299a4eb295856476 15-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Explicitly walk lists in ir_function::parameter_lists_match

Give ir_function::parameter_lists_match_exist similar treatment. Make
the parameters const, and propogate the constness as far as it will
trivially go.
r.h
r_function.cpp
de415b7f4b1278f10097f4af80886bc82912dd92 14-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Add comment about bug in initializer handling
inker.cpp
8fe8a814b0c746f0f655a67f8755f9dee858d230 14-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: First bits of intrastage, intershader function linking

This handles the easy case of linking a function in a different
compilation unit that doesn't call any functions or reference any
global variables.
akefile
ink_functions.cpp
inker.cpp
inker.h
a48a2b66e86d6d1c2fbb24bc60df2fdef42b3086 14-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> ir_function_signature: Make actual_parameters public
r.h
3880d07f4bde3f3743bad6e0f5966276c476fb21 14-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Remove some unnecessary includes
inker.cpp
61a44ccaef63a8ad36ebd934e6944ede5587e4d5 19-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> exec_list: Fix foreach_list_safe.

It now works correctly when nodes are removed, as it was originally
intended to do; it no longer processes nodes added to the list before
the current node, nor those added immediately after the current node.

This matches the behavior of Linux's list_for_each_safe.
r_hv_accept.cpp
ist.h
303c99f12fd1234a763147f9e081f2544433fc77 19-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Use foreach_list_safe in move_non_declarations

The node being processed may be removed from the list and put in a
different list. Not using the safe version caused list processing to
change streams after moving a node.
inker.cpp
9303e358cb3062f62c39961ebd4708bf63db03c1 19-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Move global instructions from the linked shader first

For the shader containing 'main', use the linked shader (i.e., the
clone of the original shader that contained main) as the source for
global instructions to move into main.
inker.cpp
5304493c40c5f450568fb518cb09940a72c1bc1d 19-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix lexing of octal values, including "0".

When faced with a constructor like 'ivec4(0, 2, 0, 0)', we would
manage to get a value of 2 instead of 0 for the first "0". Usually 2
characters past "0" would point at some junk and lex as 0 anyway.

Fixes glsl-octal and glsl-unused-varyings.
lsl_lexer.lpp
82d4b9593bd541b20771cddc1365add21dea6ba9 19-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix the expression type for atan's pi * sign(y).

Fixes CorrectFunction.vert.
uiltin_function.cpp
uiltins/110/atan
29ce44ad2b8d37ea54923f1d1856b44ef26903e5 19-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass for converting if statements to conditional assignment.

This will be used on 915 and similar hardware of that generation.
akefile
r_if_to_cond_assign.cpp
r_optimization.h
d16044ad4d6176fec6164f96450a25f76b7677f1 19-Jul-2010 Eric Anholt <eric@anholt.net> 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.
r.cpp
r.h
r_validate.cpp
1f47245bdda2c85bf0f0174e6c24a50486b413aa 19-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Remove the const disease from function signature's callee.
st_function.cpp
r.cpp
r.h
r_clone.cpp
r_reader.cpp
9be7f638130f46a9df2bfbcd4a03b36de9e4f3aa 14-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Make cross() be an expression operation.

ARB_fp, ARB_vp, Mesa IR, and the 965 vertex shader all have
instructions for cross. Shaves 12 Mesa instructions off of a
66-instruction shader I have.
uiltin_function.cpp
uiltins/110/cross
r.cpp
r.h
r_constant_expression.cpp
87a2ee8db6222006480bd0e0ac58b77795c5d951 19-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix warning from always-false assert not being known to not return.
lsl_parser_extras.cpp
643f5ea1e0402d05e71d4f0340ea8f29042b8c79 16-Jul-2010 Vinson Lee <vlee@vmware.com> glsl/apps: Handle ftell errors in non-debug builds.
pps/compile.c
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
17a307d154489d718ab51a6272d2054868d782f6 14-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Actually do type conversion on function arguments.
st_function.cpp
1fdcdb2dca97cdf4b8f4790aa66587ff3e89e526 14-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> exec_list: Add a new replace_with method.
ist.h
53120805a83a834349a96515d8e2dcbd622d06db 12-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
d5316aeb38865b3315a8a2b46f2c5bfd0d985d65 10-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Rework clamp to use scalar/vector combinations.
uiltins/110/clamp
uiltins/130/clamp
8984203abb711d5b9e763afc6afc8f52cc4f7cc2 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Rework min/max to use scalar/vector combinations.
uiltins/110/max
uiltins/110/min
uiltins/130/max
uiltins/130/min
ce5ae5f49d82b545ab204b9fdb9a8f939e0a6d78 14-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_binop_mod.
r_constant_expression.cpp
79fed377f4625da9ce6a0a32c1e7277a2e90e914 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_binop_min and ir_binop_max.

These now work on scalar/vector combos. Semantically, if a is a scalar,
min(a, vec2(x,y)) == vec2(min(a,x), min(a,y))
r_constant_expression.cpp
891a0647e419c0cd2b67e43540936bf0ac94f840 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_binop_pow.
r_constant_expression.cpp
3fab376bef8c5f407d4011b89a17ea4fd414f213 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_cos.
r_constant_expression.cpp
908afd16d1f6b5283a2535e388b6dcb77e6504d2 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_sin.
r_constant_expression.cpp
074720477ce9de3b4dafceffd7406bcebae1a3b9 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_floor.
r_constant_expression.cpp
c1ee30a14590d73217f7dbd35e6a1839435cc5b4 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_ceil.
r_constant_expression.cpp
323d909ab21c9f378903e2027fcfef5ba9e890f9 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_trunc.

This uses a C99 function.
r_constant_expression.cpp
cb63929df4ce17e94e8ead0316a00d48b51944c9 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_log2.

This uses a C99 function.
r_constant_expression.cpp
aca01edc8336fd14005a7ac853e7158f31a74940 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_exp2.

This uses a C99 function.
r_constant_expression.cpp
14b7b2660c771aa090477c11f85da998ec3d2570 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for ir_unop_sign.
r_constant_expression.cpp
5e840dba4412b33ae49289efd357a60098ac2611 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Remove bogus assert in ir_unop_abs case.

abs is defined for integral types; it's even implemented.
r_constant_expression.cpp
7d19bf2ec34dceb621ec82861be3d12ba73e67d3 14-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Remove ir_program bong hits.
r.h
c10a68522c400d48553dbd473b9778140842d9dd 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: When linking makes a variable not a varying output, make it ir_var_auto.

This almost fixes glsl-unused-varying, except that the used varying
gets assigned to the first varying slot (position).
inker.cpp
4e6a3e0d2d148747002ab9e9c1dffe63e912c688 13-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Remove unnecessary casts of clone return values
r_clone.cpp
inker.cpp
15ded6327966fa5824e34f7291e624994457f9b5 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add matrix multiplication to ir_mat_op_to_vec.
r_mat_op_to_vec.cpp
562c3d0cb1aedbf3c9f13f206678fa3f0fa26a9f 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Flatten expression that appear as the parameters of ir_call as well.
r_expression_flattening.cpp
94da2abfd49c6b4060544986ef68d5662b1cc292 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Flatten expressions that appear as the children of ir_return as well.
r_expression_flattening.cpp
31a97868fc14d4c57681c35021571b4b61f29e20 13-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Merge global-scope instructions into main

Find instructions in all shaders that are not contained in a function
(i.e., initializers for global variables). "Move" these instructions
to the top of the main function in the linked shader. As a
side-effect, many global variables will also be copied into the linked
shader.
inker.cpp
15ce87e9f2d4f66ef87af693a284b3cc9fd870c1 10-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Detect the shader that contains "main" during intrastage linking
inker.cpp
11fc7beb2fa82179cfd9202449e1365b28f868a9 13-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> ir_function: Make matching_signature not return const

The linker needs to use this function to get specific function signatures, but
it also needs to modify the returned signature. Since this method isn't itself
const (i.e., const this pointer), there is no value in making a const and
non-const version.
r.h
r_function.cpp
13f782c4ae4e38e64ec4fe87a1c24597a5e894c3 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Implement first bits of intrastage linking

This currently involves an ugly hack so that every link doesn't result
in all the built-in functions showing up as multiply defined. As soon
as the built-in functions are stored in a separate compilation unit,
ir_function_signature::is_built_in can be removed.
r.h
r_clone.cpp
r_reader.cpp
inker.cpp
e2e5d0def490ed03970efa0a7468fef0623ae617 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Refactor cross_validate_uniforms into cross_validate_globals

The later, more generic function will be used in the intra-stage linker.
inker.cpp
d74c9ff046c9cf8ee33c202eb5eba3dfc7f8e06e 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Use a better talloc context for ir_expression_flattening.

The instruction can be hung off of any other in the tree, even if the
other one will be deleted, since it'll get stolen to the shader's
context later if it's still live.
r_expression_flattening.cpp
7b96b474e06f83bf4abec42b3a9cb2dee0ea1b68 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add support for variable vector indexing on the LHS of assignments.

Fixes glsl-vs-vec4-indexing-3.
r_vec_index_to_cond_assign.cpp
b87259d3efeadf05556e2daf688935a038097bba 13-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix copy propagation in the presence of derefs in array indexes.

We would clear the in_lhs flag early, avoiding copy propagation on the
array index variable (oops) and then copy propagating on the array
variable (ouch). Just avoid all copy propagation on the LHS instead.
r_copy_propagation.cpp
506880bc32e7bb98fd1896a9b2fe3614abab904f 13-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> ir_validate: Also perform usual checks on ir_dereference_variable nodes
r_validate.cpp
8baf21b1a4d50efca086679cc43bb0cfc3fee03a 12-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> ir_validate: Validate that varibles are declared before used in IR
r_validate.cpp
3fb878722ed53d79eedb9fe68972ef32b79575d4 09-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Stub-out intrastage linker
inker.cpp
ain.cpp
c67016de960c988c748ffdb11247072543a8f328 02-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> 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.
r_validate.cpp
df05ad4e1aa5512ce1dfd2e6661641e012c8b279 02-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> ir_function_signature: Add method to get the function owning a signature

There is no setter function, the getter returns a constant pointer,
and ir_function_signature::_function is private for a reason. The
only way to make a connection between a function and function
signature is via ir_function::add_signature. This helps ensure that
certain invariants (i.e., a function signature is in the list of
signatures for its _function) are met.
r.cpp
r.h
f3235eb37f264244f4ea432700be7dd6b2930d6c 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add utility function clone_ir_list
r.h
r_clone.cpp
792e01c1e259077eb339af3ce61905fd227ae4bd 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> ir_call: Add method to set the function signature being called
r.cpp
r.h
b50098122696c00e7f9e57089197e25e5fe0e0cf 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Implement ir_function::clone and ir_function_signature::clone
r_clone.cpp
81d664f099a5fd5fac777480532fb4307d591451 13-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Move temp declaration to correct side of if-statement in IR
st_to_hir.cpp
10d222b70266a1b6e8dde90652156c6e18bcd3c8 08-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add missing fields in ir_variable::clone
r_clone.cpp
0b9ae3befb0bf80e000b159fd44c961a144f9c36 12-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add declarations for temporaries to instruction stream

Temporary variables added for &&, ||, and ?: were not being added to
the instruction stream. This resulted in either test failures or
Valgrind being angry after the original IR tree was destroyed by
talloc_free. The talloc_free caused the ir_variables to be destroyed
even though they were still referenced.
st_to_hir.cpp
288733f6001a2148d6689587d9a05e6909e88a61 12-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Store the gl_type of the array's element type in the array.

Fixes glsl-fs-uniform-array-1, glsl-vs-uniform-array-1, and the -2
tests on software.
lsl_types.cpp
6d8a0a0aadaafbab02dffcf7f89eb0210dd37b2e 12-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add a new pass at the IR level to break down matrix ops to vector ops.

This will be used by the Mesa IR and likely most HW backends, as it
allows other optimizations to occur that might not otherwise.

Fixes glsl-vs-mat-sub-1, glsl-vs-mat-div-1.
akefile
r.h
r_mat_op_to_vec.cpp
r_optimization.h
5723e5bb8b73cd2a3b77d750972e3d0b4d0d0ff8 12-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Flatten out expressions that are the child of an assignment rhs.

This feels a little odd, but it will be useful for ir_mat_to_vec,
where I want to see a plain assignment of the expression to a
variable, not to a writemasked array dereference with a call as the
array index.
r_expression_flattening.cpp
d2afc874452a84965ee71c96f80e1d124c211ff4 12-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Check when inlining a bare function call that it actually is.

It would be easy to miss an entry either of the two visitors involved
that would result in trying to ir->remove() the call to remove it from
the instruction stream when really it's part of an expression tree
that wasn't flattened.
r_function_inlining.cpp
284d821206d74fddb346cd0d892d2dcec463e2a5 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Fix non-float constructors with matrix arguments.

Previously, code like ivec4(mat2(...)) would fail because the compiler
would naively try to convert a mat2 to an imat2...which doesn't exist.
Now, a separate pass breaks such matrices down to their columns, which
can be converted from vec2 to ivec2.

Fixes piglit tests constructor-11.vert, constructor-14.vert,
constructor-15.vert, and CorrectConstFolding2.frag.
st_function.cpp
f58bbd134e921b14f50ecd1e76b2943753ba194c 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Move error return earlier and don't indent the world.

This has no functional changes.
st_function.cpp
59df3385e1c413332c75be5d0e7751972d45430e 09-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ast_function: Remove unnecessary check for empty constructors.

This case is already caught by a later check that ensures sufficient
components were provided, based on the type.
st_function.cpp
a4dde28ee6893ab99c6ca93699392bb8bc2d981c 08-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Use new foreach_list_safe abstraction.
r_hv_accept.cpp
f3290e950cd78a423d380b7e0a7aa18eb7718e27 08-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add foreach_list_safe which works even when mutating the list.

In particular, with foreach_list_safe, one can remove and free the current
node without crashes; if new nodes are added after the current node,
they will be properly visited as well.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
ist.h
dfd30ca6a95a7d95835dad78ffe1fba4d1f4ef69 08-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Remove generate_temporary and global temporary counter.

Most places in the code simply use a static name, which works because
names are never used to look up an ir_variable. generate_temporary is
simply unnecessary (and looks like it would leak memory, and isn't
thread safe...)
st_to_hir.cpp
lsl_parser_extras.h
ain.cpp
152b55e74da7bf548d8846538b85960f703d6059 08-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add support for gl_PointCoord in 1.20.

Fixes glsl-fs-pointcoord on swrast (remains broken on 965, like master)
uiltin_variables.h
r_variable.cpp
e024c5c6900c068634c2726d9ccfb9beac966c57 08-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Don't emit ir_function multiple times.
r_reader.cpp
35c89204e597e6d4d3e8b8c665ce1c51d6dde4d7 08-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Use bit-0 instead of VERT_BIT_GENERIC0

Uses of the bits for allocation are offset by 16, and
VERT_BIT_GENERIC0 already has the 16 offset. As a result, it was
preventing the wrong thing from being allocated.
inker.cpp
0b74bbb3dcf07489e1dbd1976f07093ad7821e51 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl: Fix the setup of refract()'s output for vec3/vec4 and k < 0.0.

caught by valgrind.
uiltin_function.cpp
uiltins/110/refract
9cbd8a1d5a85f39f12e9edbd2defbb9e9d0468ef 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix ir_div_to_mul_rcp for integer division.

rcp of an integer value did not produce the result you're looking for.
Instead, do the a * rcp(b) as float and truncate after. This mostly
fixes glsl-fs-loop-nested.
r_div_to_mul_rcp.cpp
43b5b03d67ce890e867c81d4a5cfc4871d711d43 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Actually add the declaration of _post_incdec_temp.
st_to_hir.cpp
acf88f2769c15c9185abe5bd76a885218f431e58 07-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Fix loop increments.
r_constant_expression.cpp
388ab9fa6b468d8c162dd4fc645d2f758c49051c 07-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Initialize yylineno and yycolumn so line numbers are sane.
lcpp/glcpp-lex.l
lsl_lexer.lpp
e78e0fa42b49b50ed1150f7fdb74bf942ebd6bcf 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Put the initializer in the instruction stream after the declaration
st_to_hir.cpp
c44556317abf77ca6e344c79d119c91bebe25c8c 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> exec_list: Add method to append one complete list to another
ist.h
2e85f993d8a014b53ad2f6d295cf66d3fb38b091 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> Revert "glsl2: Put the declaration in the instruction stream before its initializer."

This change causes segfaults in other tests. A fix for both sets of
segfaults is coming.

This reverts commit d4d630b72c7b7f38074addda0f1b819608247d93.
st_to_hir.cpp
d674ebcee0d2731e50d6530502cefcebc39dcdb6 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass to simplify if statements returning from both sides.

This allows function inlining making the following tests work even
without function calls implemented:
glsl-fs-functions-2
glsl-fs-functions-3
glsl-vs-functions
glsl-vs-functions-2
glsl-vs-functions-3
glsl-vs-vec4-indexing-5

(Note that those tests were designed to trigger actual function calls,
and this defeats them. However, those testcases ended up catching the
bug in the previous commit.)
akefile
r_if_return.cpp
r_optimization.h
6de882334ac7f3d32d04261adfed1397e075ffd5 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Clean up vec_index_to_cond_assign after the clone return type change.
r_vec_index_to_cond_assign.cpp
773025b92c934014b9ceb4ebfdabcfc9d8587aa2 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Don't forget to walk the parameters to a function in the hv.

Fixes segfaults from use after free after the steal of ir nodes and
free of the compile context.
r_hv_accept.cpp
570dc0d4004bf09d257b3e4c8664d3c26a8af510 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Avoid null deref in scalar constant unop expressions.
r_constant_expression.cpp
d4d630b72c7b7f38074addda0f1b819608247d93 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Put the declaration in the instruction stream before its initializer.

This fixes a regression in the generated code from when I did the
ir_validate.cpp-driven rework of assignments.
st_to_hir.cpp
a36334be02cb0a2b834667116bfeb680bf365857 07-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add pass for supporting variable vector indexing in rvalues.

The Mesa IR needs this to support vector indexing correctly, and
hardware backends such as 915 would want this behavior as well.

Fixes glsl-vs-vec4-indexing-2.
akefile
r_optimization.h
r_vec_index_to_cond_assign.cpp
ain.cpp
ca088cc277ce9f986693c857f3961dc0e1a4d91c 07-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Clone methods return the type of the thing being cloned

This is as opposed to returning the type of the base class of the hierarchy.
st_to_hir.cpp
r.h
r_clone.cpp
r_constant_expression.cpp
r_function_inlining.cpp
f14e596f11b4e44c75a880536efb1e8c5a72da7d 07-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Declare loop counting variables in the loops.

Fixes "name lookup of 'c' changed" warning.
r_constant_expression.cpp
f2dfac6d7455b6bf95cb94bd9ba296dea5c93faf 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Update TODO.
ODO
3f4a0b8bb0cfa36cc6f9968c8aab03f1cb0678ff 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for dot products.
r_constant_expression.cpp
cf80a4d177225345c2238d8e545f8ae02b41da71 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Add support for matrix multiplication.

Also handles matrix/vector and vector/matrix multiplication.

Fixes piglit tests const-matrix-multiply-01.frag,
const-matrix-multiply-02.frag, and const-vec-mat.frag.
r_constant_expression.cpp
37b3f9d0edb55807f822c02292348e20a8369c43 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Support scalar * vector and scalar * matrix.

The test here is slightly different since we need to keep matrix
multiplication separate.

Fixes piglit tests const-vec-scalar-03.frag and const-mat-scalar-03.frag.
r_constant_expression.cpp
dad35eb8b0c7378588d9dca1c1091aaede83a83f 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Support scalar / vector and scalar / matrix.

Fixes piglit tests const-vec-scalar-04.frag and const-mat-scalar-04.frag.
r_constant_expression.cpp
97b44f040abc9cbf257aba1b7fdaa11134dcc70b 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Support scalar - vector and scalar - matrix.

Fixes piglit tests const-vec-scalar-02.frag and const-mat-scalar-02.frag.
r_constant_expression.cpp
e74dcd7924901e5cb3d0952f46e955e15d0b3207 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Support scalar + vector and scalar + matrix.

Fixes piglit tests const-vec-scalar-01.frag, const-vec-scalar-05.frag,
and const-mat-scalar-01.frag.
r_constant_expression.cpp
6fc983b9bb5555e2906d2680bc3cbd11c43b63f6 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Assert that both operands share a base type.
r_constant_expression.cpp
6bc432e14e12c280bc53e57338bf86fbf8d26885 03-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Initialize op[0] and op[1] to NULL.

This makes it easy to check if there is a second argument.
r_constant_expression.cpp
c63a1db81f56cc2021fe1fb2411c327f720b0e09 06-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> ir_constant_expression: Initialize all components of constant data to 0.

This is probably just a good idea, and will come in useful when
implementing things like matrix multiplication.
r_constant_expression.cpp
d1a1ee583e7e8338243b3e9768d2fc5312a1145d 06-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> Add hash table helper functions for using pointers as hash keys
r_function_inlining.cpp
r_validate.cpp
83035574dbe0e225fbdeb9ceb4f0af9b0e0c5ddb 03-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> Refresh autogenerated file builtin_function.cpp.
uiltin_function.cpp
7e908a6a27f196027a4dfd0f4d8c37aa71e163fa 03-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add #error support.
lcpp/glcpp-lex.l
2070f9f5bec99e7b91309060984431aa7ea32c00 03-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Fix for dead strings being stored in the symbol table.
r_reader.cpp
ddc3aa07832c3fa35382b57ce2539dbac5a6158d 02-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Use vector ops in the 130 version of "sign."
uiltins/130/sign
9a7ac272fb7d87e56277ed88585f389446a4a1b9 02-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2/builtins: Use vector ops in "smoothstep."
uiltins/110/smoothstep
4d962e66e319191d5b94291b6f55d720df71130a 02-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Print the linking info log in the stand-alone compiler
ain.cpp
9a0e421983edc31371440c08687fa2bb2207924d 02-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass to break ir_binop_div to _mul and _rcp.

This results in constant folding of a constant divisor.
akefile
r_div_to_mul_rcp.cpp
r_optimization.h
667f4e1940c4c4660e35dc9906672a476369660f 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Conditionally allow optional extensions to be enabled

The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
lsl_parser_extras.cpp
lsl_parser_extras.h
ain.cpp
efb6b24223e0bfd29959e131cd308b1e07ff20df 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Append _TOK to some parser tokens

This prevents conflicts with defines elsewhere in Mesa and allows
including mtypes.h in the compiler.
lsl_lexer.lpp
lsl_parser.ypp
06143ea09411aa283ac3633bfbfa4326584cd952 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Conditionally define preprocessor tokens for optional extensions

The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
lcpp/glcpp-parse.y
lcpp/glcpp.c
lcpp/glcpp.h
lcpp/pp.c
lsl_parser_extras.h
ain.cpp
2d1223611700b33aab084f1927bfc1ff1b284115 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Define preprocessor tokens for extensions

Currently only GL_ARB_draw_buffers and GL_ARB_texture_rectangle are
defined because those extensions are always enabled. This make
tex_rect-03.frag pass.
lcpp/glcpp-parse.y
6f0823da09384cc1b557385b9e19a9cc7e901ad7 02-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Support AST-to-IR translation of invariant keyword
st_to_hir.cpp
3832706f81d7f5310882eda6d7ef0c3e39593b18 02-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Initialize ast_declarator_list::invariant in constructor
lsl_parser_extras.cpp
12873fa4e332959295154edfe957c0af79af5e74 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Don't bounds check unsize array redeclarations

This along with several previous commits fix test CorrectUnsizedArray.frag.
st_to_hir.cpp
127308b4be077e5bdf60f76320307550921e86bb 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add gl_MaxTextureCoords
st_to_hir.cpp
lsl_parser_extras.h
r_variable.cpp
ain.cpp
cd00d5b88caa41ebf4b407126f314832f9fdae54 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Default delcaration of gl_TexCoord is unsized
st_to_hir.cpp
r_variable.cpp
5466b63968b98c9627b8dd207ea2bebf838b5268 01-Jul-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Change order of semaintic checks on variable declarations

This will make it easier to support more (valid) kinds of redeclarations.
st_to_hir.cpp
d1b07167b947715577a45b9d9b256c846f3964c6 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Update README for what I've been thinking about with expr types work.
EADME
8a1f186cc55979bb9df0a88b48da8d81460c3e7c 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add a pass to convert mod(a, b) to b * fract(a/b).

This is used by the Mesa IR backend to implement mod, fixing glsl-fs-mod.
akefile
r.h
r_hierarchical_visitor.cpp
r_hierarchical_visitor.h
r_hv_accept.cpp
r_mod_to_fract.cpp
r_optimization.h
9acf618f24428eba72650c0e328e7ed52986728e 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Remove dead member from dead code visitor.
r_dead_code.cpp
d925c9173009e9e5d48df30b30aaef22753183aa 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Add ir_unop_fract as an expression type.

Most backends will prefer seeing this to seeing (a - floor(a)), so
represent it explicitly.
uiltin_function.cpp
uiltins/110/fract
r.cpp
r.h
r_constant_expression.cpp
f5b3b2a01a320d136df3cf1f8c6fa78685d164d1 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Don't break sign() down by vector components.
uiltin_function.cpp
uiltins/110/sign
02d615306eb930bd6de9f1503ddd54ee33d3b930 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix reversed value of step().

It's 0.0 if x < edge, not 1.0. Partial fix for glsl-fs-step.
uiltin_function.cpp
uiltins/110/step
4e16a7b526bb4736cd11e512009cf6532b2d1dc5 01-Jul-2010 Eric Anholt <eric@anholt.net> glsl2: Fix up the implementation of fract() for vector types.

There's no need to split each vector component out, just do vector ops.
uiltin_function.cpp
uiltins/110/fract
77049a702ad54e09c4102fe8c964e069944f83e5 30-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Implement AST->HIR support for the "discard" instruction.
st_to_hir.cpp
16efab1c4dee6e6a827ba5f1c482378159545ae5 30-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Define new ir_discard instruction.
r.h
r_clone.cpp
r_constant_expression.cpp
r_constant_folding.cpp
r_hierarchical_visitor.cpp
r_hierarchical_visitor.h
r_hv_accept.cpp
r_print_visitor.cpp
r_print_visitor.h
r_visitor.h
97eba76b8c5fe60738716c4dce9404de417a7d34 30-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Allow a fragment shader to not write a color.

I can't find any text justifying this check, and it caused a
reasonable-looking shader in glsl-bug-22603 (which writes only
gl_FragDepth) to fail.
inker.cpp
c7f4ff193a6f7cfae2e4cdc6c4b9162a16226dc0 30-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Fix storing of dead memory in the symbol table.

decl->identifier is part of the AST, so it doesn't live very long.
Instead, add var->name which is owned by var.
st_to_hir.cpp
629198b96a8f471c48932d6af56184b6c33b5fe5 29-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Preprocessed source doesn't need to live past compile time.
ain.cpp
c6099a65f8f8310a540f7c19cfc380ad980c9dd7 25-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Create new talloc contexts the "right" way.
r_copy_propagation.cpp
r_dead_code_local.cpp
953ff1283d3d52e6a6b4850c2b0b574111625010 25-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.

_mesa_glsl_parse_state should be the parent for all temporary allocation
done while compiling a shader. glsl_shader should only be used as the
parent for the shader's final IR---the _result_ of compilation.

Since many IR instructions may be added or discarded during optimization
passes, IR should not ever be allocated to glsl_shader directly.

Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g.

This also removes a ton of talloc_parent calls, which may help performance.
st_function.cpp
st_to_hir.cpp
lsl_lexer.lpp
lsl_parser.ypp
ir_field_selection.cpp
r_reader.cpp
116f1d4f95d8eb0a82b272016590549632c865b3 25-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Steal the live IR and free the rest of the junk.
ain.cpp
ef5f1948316664055c1444d12076c7d86589a8b9 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Don't dynamically allocate slots for linked shaders

The can be at most one shader per stage. There are currently only two
stages. There is zero reason to dynamically size this array.
inker.cpp
982e3798d8b9bfec7ff3f37c52687036b36bc153 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> linker: Don't automatically allocate VERT_ATTRIB_GENERIC0
inker.cpp
849e18153cd91d812f694b806a84008498860bc3 30-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Use Mesa's gl_shader_program instead of our own struct glsl_program.

This avoids more allocation and shuffling of data around.
inker.cpp
ain.cpp
rogram.h
0eda9ae0a6bcd6a7e014df046c87fac5caee0e9e 30-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Make function names and variable names be children of the node.

This avoids losing their memory when the parser state is freed.
r.cpp
16b68b1952d0da14b9ce8306efa64988ce46b4b7 30-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Move our data from a glsl_shader* on the side to the main gl_shader *.

This saves recompiling at link time. gl_shader->ir is made a pointer
so that we don't have to bring exec_list into mtypes.h.
inker.cpp
ist.h
ain.cpp
rogram.h
0d68d01347383a8878c9678706cc3bd212b54bbd 30-Jun-2010 Zack Rusin <zackr@vmware.com> mesa: make the arguments in the asm statemants optional

geometry shaders emit/end functions don't take any arguments
l/sl_cl_parse.c
d4f7e660dd81e05b0829c1b70663b3959fd78f47 29-Jun-2010 Eric Anholt <eric@anholt.net> ir_to_mesa: Start adding support for texture instructions.

Fixes:
glsl-fs-bug25902
glsl-fs-sampler-numbering
glsl-lod-bias
r.h
506199b852390e14a1d78392285bee8f06b6ede7 30-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Keep the same number of components in implicit conversions.

Fixes piglit test glsl-implicit-conversion-01.
st_to_hir.cpp
22971e922a72c8a433638429b635935fe80907ee 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Make gl_MaxDrawBuffers available in the vertex shader
r_variable.cpp
e2f84f04e5df1d4364694e5f150058f7c847550e 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Make gl_MaxDrawBuffers available in the fragment shader
r_variable.cpp
9c4b1f2bad97b1b83c6bf01db567be5494dfaee5 30-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Make gl_FragData be available in GLSL 1.10 too
r_variable.cpp
5e18b051c039564d1998818d08caf1bff3983630 29-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Pass MaxDrawBuffers from core Mesa into the GLSL compiler
lsl_parser_extras.h
r_variable.cpp
ain.cpp
efc15f862b08a9f035c06a79bc43848cca740372 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Add _mesa_glsl_release_types to release all type related storage
lsl_types.cpp
lsl_types.h
ain.cpp
e1374d48ded09dba576f5a2b86c3d11984d1f7c4 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: All glsl_type objects live in their own talloc context
lsl_types.cpp
lsl_types.h
72e627d02a78cbf40c861384293e355588fd0977 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Record type constructors are private
lsl_types.cpp
lsl_types.h
49e3577b91f44013746f7a3db411e7041b7d899e 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Add get_record_instance method
st_to_hir.cpp
lsl_types.cpp
lsl_types.h
31bcce04b1f9c8c5e33370e26a3a9d6e60049aa8 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Vector, matrix, and sampler type constructors are private
lsl_types.cpp
lsl_types.h
e94642eb0d99ff7f6cdaee31ed4f5f29bdabd6f7 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Make all static objects be class private
uiltin_types.h
lsl_types.cpp
lsl_types.h
4b6feb0398458a69259e3b77d7a8573b926f2039 28-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use talloc_strdup when generating constructor temporary names
st_function.cpp
12681610f54b40324e9e342dc25976c223614b81 26-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl_type: Remove vector and matrix constructor generators

All scalar, vector, and matrix constructors are generated in-line
during AST-to-HIR translation. There is no longer any need to
generate function versions of the constructors.
st_to_hir.cpp
lsl_types.cpp
lsl_types.h
699b247661b1c70e890e478dba88253cad035969 26-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Don't flatten constructor parameters to scalars

Now that all scalar, vector, and matrix constructors are emitted
in-line, the parameters to these constructors should not be flattened
to a pile of scalars. Instead, the functions that emit the in-line
constructor bodies can directly write the parameters to the correct
locations in the objects being constructed.
st_function.cpp
81c7e94466da19f9295b8eb5e4b5e587fea96284 26-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Always emit matrix constructors inline
st_function.cpp
c31dcdf57ed9646580040ebfe44c2609885fe96b 24-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Always emit vector constructors inline
st_function.cpp
6315b68f5fbe529bce3497b67c42af1eaa62b8c1 26-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> ir_swizzle: Add new constructor, refactor constructors

Adds a new constructor that takes an array of component values. Refactors
the meat of the two constructors to an init_mask method.
r.cpp
r.h
50577b96ac07bc24af1ef8e2490cb633aa84dd7d 29-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Update TODO.
ODO
6de825650560198eb97f19e72b2d56e68e3d7a63 29-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Check for non-void functions that don't have a return statement.

This doesn't do any control flow analysis to ensure that the return
statements are actually reached.

Fixes piglit tests function5.frag and function-07.vert.
st_to_hir.cpp
lsl_parser_extras.h
ac04c257e31fe012dac750bcf5bf3134ba07ebdc 29-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Reject return types with qualifiers.

Fixes piglit test return-qualifier.frag.
st_to_hir.cpp
28527ed557923aecff5d3b88e5d7776f04389547 29-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Add a method for querying if an AST type has any qualifiers.
st.h
st_type.cpp
18707eba1cd6c07fa8b63d0ba5b26f6433f1ae91 29-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Check that returned expressions match the function return type.

From my reading of the specification, implicit conversions are not
allowed. ATI seems to agree, though nVidia allows it without warning.
st_to_hir.cpp
da7bd6a90e1fee5c16327338fd251c0f6be34e36 28-Jun-2010 Zack Rusin <zackr@vmware.com> mesa: initial support for ARB_geometry_shader4

laying down the foundation for everything and implementing most of the
stuff.
linking, gl_VerticesIn and multidimensional inputs are left.
pps/compile.c
l/sl_cl_parse.c
5f3fe44595e53874908d1f047405d27861f1df0f 25-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> Use a more sensible context in copy propagation.
r_copy_propagation.cpp
a815f7fb83b1117e957c097044f36eae3a6851fb 25-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> Use more sensible contexts in ir_dead_code_local.
r_dead_code_local.cpp
22c23dedad4e7f362ffbd990f1c2d5caf4cae75a 26-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Add option to stand-alone GLSL compiler to dump IR before optimizations
ain.cpp
26b5d33dce37755a6a4a799a9edfcdff8c5ce3e5 26-Jun-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use i2b and f2b IR opcodes for casting int or float to bool
st_function.cpp
78062273de65bf8133f2550aa2a26040a82a65aa 25-Jun-2010 Kenneth Graunke <kenneth@whitecape.org> ir_reader: Free memory for S-Expressions earlier.

There's no point in keeping it around once we've read the IR.

Also, remove an unnecessary talloc_parent call.
r_reader.cpp
0fd97db8b077ad1bd5d26e86e67ebb2d58b6a38a 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Associate the GLenum for the type with builtin GLSL types.
uiltin_types.h
lsl_types.h
bda27424cf04c0d2ec2b49c56f562d5b2d2f0bff 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Use the parser state as the talloc context for dead code elimination.

This cuts runtime by around 20% from talloc_parent() lookups.
r_dead_code.cpp
r_optimization.h
ain.cpp
364fcd8ee1af39e215338fba59306a14dd81c2b2 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Start integrating ir_to_mesa.cpp into shader_api.h

The compiler is now called by the driver, and generates program
instructions. Parameter lists are still not set up, so the driver
chokes on it shortly thereafter.
rogram.h
7f2bf62d25b2fdc059163ee046cf2fe007e5041e 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Use Mesa types instead of duping them into our program.h.
rogram.h
2a3d46dd46779136e14c3e939a5b761c58576862 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Fix dependencies. (at least partially)
akefile
0a1b54df7ac118722bb627c61cb322cb4e248ace 21-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Replace the GLSL compiler with the glsl2 project.
akefile
akefile.am
3d6012303c3ce24c75d209267e6914f706d025c5 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Wrap includes of C interfaces with extern "C".
st_type.cpp
lsl_symbol_table.h
lsl_types.cpp
r_clone.cpp
r_function_inlining.cpp
r_validate.cpp
inker.cpp
f4869f33269c54779f8199b68e769024100421a3 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Remove files that had been imported for standalone.
ash_table.c
ash_table.h
ain/imports.h
ain/mtypes.h
ain/simple_list.h
esa/shader/prog_instruction.c
esa/shader/prog_instruction.h
esa/shader/prog_print.c
esa/shader/prog_print.h
ymbol_table.c
ymbol_table.h
e82ddb781ad100702322eb465e82b1cec433f099 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Stop .gitignoring the old standalone build system.
gitignore
9aa0b6d728dafc40a65d1a45aa0830f87d76cb23 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Move the Mesa IR codegen into mesa/shader/
r_to_mesa.cpp
bcc13b74443137043e8a34f8cb64a5add0d8af93 25-Jun-2010 Eric Anholt <eric@anholt.net> Merge branch 'glsl2-head' into glsl2

This brings in the standalone GLSL compiler that we are planning on
replacing the existing Mesa GLSL compiler. It currently targets GLSL
1.20 and the Mesa IR.
e5cf3aadb8d57dcc70b597092ecac276042f73cb 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Add a README file for the new compiler.
EADME
29285882676388aacff123e8bdf025904abf8ea9 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Move the compiler to the subdirectory it will live in in Mesa.
dir-locals.el
gitignore
akefile.am
ODO
st.h
st_expr.cpp
st_function.cpp
st_to_hir.cpp
st_type.cpp
utogen.sh
uiltin_function.cpp
uiltin_types.h
uiltin_variables.h
uiltins/110/abs
uiltins/110/all
uiltins/110/any
uiltins/110/asin
uiltins/110/atan
uiltins/110/ceil
uiltins/110/clamp
uiltins/110/cos
uiltins/110/cross
uiltins/110/degrees
uiltins/110/distance
uiltins/110/dot
uiltins/110/equal
uiltins/110/exp
uiltins/110/exp2
uiltins/110/faceforward
uiltins/110/floor
uiltins/110/fract
uiltins/110/greaterThan
uiltins/110/greaterThanEqual
uiltins/110/inversesqrt
uiltins/110/length
uiltins/110/lessThan
uiltins/110/lessThanEqual
uiltins/110/log
uiltins/110/log2
uiltins/110/matrixCompMult
uiltins/110/max
uiltins/110/min
uiltins/110/mix
uiltins/110/mod
uiltins/110/noise_fake
uiltins/110/normalize
uiltins/110/not
uiltins/110/notEqual
uiltins/110/pow
uiltins/110/radians
uiltins/110/reflect
uiltins/110/refract
uiltins/110/sign
uiltins/110/sin
uiltins/110/smoothstep
uiltins/110/sqrt
uiltins/110/step
uiltins/110/tan
uiltins/110/textures
uiltins/110_fs/derivatives
uiltins/110_fs/textures
uiltins/110_vs/ftransform
uiltins/120/matrixCompMult
uiltins/120/outerProduct
uiltins/120/transpose
uiltins/130/clamp
uiltins/130/cosh
uiltins/130/equal
uiltins/130/greaterThan
uiltins/130/greaterThanEqual
uiltins/130/lessThan
uiltins/130/lessThanEqual
uiltins/130/max
uiltins/130/min
uiltins/130/notEqual
uiltins/130/sign
uiltins/130/sinh
uiltins/130/tanh
uiltins/130/texelFetch
uiltins/130/texture
uiltins/130/textureGrad
uiltins/130/textureLod
uiltins/130/textureProj
uiltins/130/textureProjGrad
uiltins/130/textureProjLod
uiltins/130_fs/texture
uiltins/130_fs/textureProj
uiltins/ARB_texture_rectangle/textures
uiltins/EXT_texture_array/textures
uiltins/EXT_texture_array_fs/textures
uiltins/tools/generate_builtins.pl
uiltins/tools/generate_matrixCompMultGLSL.py
uiltins/tools/generate_outerProductGLSL.py
uiltins/tools/generate_transposeGLSL.py
uiltins/tools/texture_builtins.py
onfigure.ac
lcpp/.gitignore
lcpp/Makefile.am
lcpp/README
lcpp/glcpp-lex.l
lcpp/glcpp-parse.y
lcpp/glcpp.c
lcpp/glcpp.h
lcpp/hash_table.c
lcpp/hash_table.h
lcpp/main/imports.h
lcpp/main/simple_list.h
lcpp/pp.c
lcpp/tests/000-content-with-spaces.c
lcpp/tests/000-content-with-spaces.c.expected
lcpp/tests/001-define.c
lcpp/tests/001-define.c.expected
lcpp/tests/002-define-chain.c
lcpp/tests/002-define-chain.c.expected
lcpp/tests/003-define-chain-reverse.c
lcpp/tests/003-define-chain-reverse.c.expected
lcpp/tests/004-define-recursive.c
lcpp/tests/004-define-recursive.c.expected
lcpp/tests/005-define-composite-chain.c
lcpp/tests/005-define-composite-chain.c.expected
lcpp/tests/006-define-composite-chain-reverse.c
lcpp/tests/006-define-composite-chain-reverse.c.expected
lcpp/tests/007-define-composite-recursive.c
lcpp/tests/007-define-composite-recursive.c.expected
lcpp/tests/008-define-empty.c
lcpp/tests/008-define-empty.c.expected
lcpp/tests/009-undef.c
lcpp/tests/009-undef.c.expected
lcpp/tests/010-undef-re-define.c
lcpp/tests/010-undef-re-define.c.expected
lcpp/tests/011-define-func-empty.c
lcpp/tests/011-define-func-empty.c.expected
lcpp/tests/012-define-func-no-args.c
lcpp/tests/012-define-func-no-args.c.expected
lcpp/tests/013-define-func-1-arg-unused.c
lcpp/tests/013-define-func-1-arg-unused.c.expected
lcpp/tests/014-define-func-2-arg-unused.c
lcpp/tests/014-define-func-2-arg-unused.c.expected
lcpp/tests/015-define-object-with-parens.c
lcpp/tests/015-define-object-with-parens.c.expected
lcpp/tests/016-define-func-1-arg.c
lcpp/tests/016-define-func-1-arg.c.expected
lcpp/tests/017-define-func-2-args.c
lcpp/tests/017-define-func-2-args.c.expected
lcpp/tests/018-define-func-macro-as-parameter.c
lcpp/tests/018-define-func-macro-as-parameter.c.expected
lcpp/tests/019-define-func-1-arg-multi.c
lcpp/tests/019-define-func-1-arg-multi.c.expected
lcpp/tests/020-define-func-2-arg-multi.c
lcpp/tests/020-define-func-2-arg-multi.c.expected
lcpp/tests/021-define-func-compose.c
lcpp/tests/021-define-func-compose.c.expected
lcpp/tests/022-define-func-arg-with-parens.c
lcpp/tests/022-define-func-arg-with-parens.c.expected
lcpp/tests/023-define-extra-whitespace.c
lcpp/tests/023-define-extra-whitespace.c.expected
lcpp/tests/024-define-chain-to-self-recursion.c
lcpp/tests/024-define-chain-to-self-recursion.c.expected
lcpp/tests/025-func-macro-as-non-macro.c
lcpp/tests/025-func-macro-as-non-macro.c.expected
lcpp/tests/026-define-func-extra-newlines.c
lcpp/tests/026-define-func-extra-newlines.c.expected
lcpp/tests/027-define-chain-obj-to-func.c
lcpp/tests/027-define-chain-obj-to-func.c.expected
lcpp/tests/028-define-chain-obj-to-non-func.c
lcpp/tests/028-define-chain-obj-to-non-func.c.expected
lcpp/tests/029-define-chain-obj-to-func-with-args.c
lcpp/tests/029-define-chain-obj-to-func-with-args.c.expected
lcpp/tests/030-define-chain-obj-to-func-compose.c
lcpp/tests/030-define-chain-obj-to-func-compose.c.expected
lcpp/tests/031-define-chain-func-to-func-compose.c
lcpp/tests/031-define-chain-func-to-func-compose.c.expected
lcpp/tests/032-define-func-self-recurse.c
lcpp/tests/032-define-func-self-recurse.c.expected
lcpp/tests/033-define-func-self-compose.c
lcpp/tests/033-define-func-self-compose.c.expected
lcpp/tests/034-define-func-self-compose-non-func.c
lcpp/tests/034-define-func-self-compose-non-func.c.expected
lcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c
lcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected
lcpp/tests/036-define-func-non-macro-multi-token-argument.c
lcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected
lcpp/tests/037-finalize-unexpanded-macro.c
lcpp/tests/037-finalize-unexpanded-macro.c.expected
lcpp/tests/038-func-arg-with-commas.c
lcpp/tests/038-func-arg-with-commas.c.expected
lcpp/tests/039-func-arg-obj-macro-with-comma.c
lcpp/tests/039-func-arg-obj-macro-with-comma.c.expected
lcpp/tests/040-token-pasting.c
lcpp/tests/040-token-pasting.c.expected
lcpp/tests/041-if-0.c
lcpp/tests/041-if-0.c.expected
lcpp/tests/042-if-1.c
lcpp/tests/042-if-1.c.expected
lcpp/tests/043-if-0-else.c
lcpp/tests/043-if-0-else.c.expected
lcpp/tests/044-if-1-else.c
lcpp/tests/044-if-1-else.c.expected
lcpp/tests/045-if-0-elif.c
lcpp/tests/045-if-0-elif.c.expected
lcpp/tests/046-if-1-elsif.c
lcpp/tests/046-if-1-elsif.c.expected
lcpp/tests/047-if-elif-else.c
lcpp/tests/047-if-elif-else.c.expected
lcpp/tests/048-if-nested.c
lcpp/tests/048-if-nested.c.expected
lcpp/tests/049-if-expression-precedence.c
lcpp/tests/049-if-expression-precedence.c.expected
lcpp/tests/050-if-defined.c
lcpp/tests/050-if-defined.c.expected
lcpp/tests/051-if-relational.c
lcpp/tests/051-if-relational.c.expected
lcpp/tests/052-if-bitwise.c
lcpp/tests/052-if-bitwise.c.expected
lcpp/tests/053-if-divide-and-shift.c
lcpp/tests/053-if-divide-and-shift.c.expected
lcpp/tests/054-if-with-macros.c
lcpp/tests/054-if-with-macros.c.expected
lcpp/tests/055-define-chain-obj-to-func-parens-in-text.c
lcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected
lcpp/tests/056-macro-argument-with-comma.c
lcpp/tests/056-macro-argument-with-comma.c.expected
lcpp/tests/057-empty-arguments.c
lcpp/tests/057-empty-arguments.c.expected
lcpp/tests/058-token-pasting-empty-arguments.c
lcpp/tests/058-token-pasting-empty-arguments.c.expected
lcpp/tests/059-token-pasting-integer.c
lcpp/tests/059-token-pasting-integer.c.expected
lcpp/tests/060-left-paren-in-macro-right-paren-in-text.c
lcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected
lcpp/tests/061-define-chain-obj-to-func-multi.c
lcpp/tests/061-define-chain-obj-to-func-multi.c.expected
lcpp/tests/062-if-0-skips-garbage.c
lcpp/tests/062-if-0-skips-garbage.c.expected
lcpp/tests/063-comments.c
lcpp/tests/063-comments.c.expected
lcpp/tests/064-version.c
lcpp/tests/064-version.c.expected
lcpp/tests/065-if-defined-parens.c
lcpp/tests/065-if-defined-parens.c.expected
lcpp/tests/071-punctuator.c
lcpp/tests/071-punctuator.c.expected
lcpp/tests/072-token-pasting-same-line.c
lcpp/tests/072-token-pasting-same-line.c.expected
lcpp/tests/099-c99-example.c
lcpp/tests/099-c99-example.c.expected
lcpp/tests/glcpp-test
lcpp/xtalloc.c
lsl_lexer.lpp
lsl_parser.ypp
lsl_parser_extras.cpp
lsl_parser_extras.h
lsl_symbol_table.h
lsl_types.cpp
lsl_types.h
ash_table.c
ash_table.h
ir_field_selection.cpp
r.cpp
r.h
r_basic_block.cpp
r_basic_block.h
r_clone.cpp
r_constant_expression.cpp
r_constant_folding.cpp
r_constant_variable.cpp
r_copy_propagation.cpp
r_dead_code.cpp
r_dead_code_local.cpp
r_expression_flattening.cpp
r_expression_flattening.h
r_function.cpp
r_function_can_inline.cpp
r_function_inlining.cpp
r_function_inlining.h
r_hierarchical_visitor.cpp
r_hierarchical_visitor.h
r_hv_accept.cpp
r_if_simplification.cpp
r_optimization.h
r_print_visitor.cpp
r_print_visitor.h
r_reader.cpp
r_reader.h
r_swizzle_swizzle.cpp
r_to_mesa.cpp
r_validate.cpp
r_variable.cpp
r_vec_index_to_swizzle.cpp
r_visitor.h
inker.cpp
ist.h
ain.cpp
ain/imports.h
ain/mtypes.h
ain/simple_list.h
esa/shader/prog_instruction.c
esa/shader/prog_instruction.h
esa/shader/prog_print.c
esa/shader/prog_print.h
rogram.h
_expression.cpp
_expression.h
ymbol_table.c
ymbol_table.h
ests/array-01.glsl
ests/array-02.glsl
ests/array-03.glsl
ests/array-04.glsl
ests/array-05.glsl
ests/array-06.glsl
ests/array-07.glsl
ests/array-08.glsl
ests/array-09.glsl
ests/array-10.glsl
ests/array-11.glsl
ests/array-12.glsl
ests/array-13.glsl
ests/attribute-01.glsl
ests/attribute-02.glsl
ests/attribute-03.glsl
ests/attribute-04.glsl
ests/attribute-05.glsl
ests/attribute-06.glsl
ests/attribute-07.glsl
ests/attribute-08.glsl
ests/attribute-09.glsl
ests/attribute-10.glsl
ests/attribute-11.glsl
ests/condition-01.glsl
ests/condition-02.glsl
ests/condition-03.glsl
ests/condition-04.glsl
ests/condition-05.glsl
ests/constructor-01.glsl
ests/constructor-02.glsl
ests/constructor-03.glsl
ests/constructor-04.glsl
ests/constructor-05.glsl
ests/constructor-06.glsl
ests/constructor-07.glsl
ests/constructor-08.glsl
ests/constructor-09.glsl
ests/function-01.glsl
ests/function-02.glsl
ests/function-03.glsl
ests/function-04.glsl
ests/function-05.glsl
ests/if-01.glsl
ests/if-02.glsl
ests/if-03.glsl
ests/if-04.glsl
ests/matrix-01.glsl
ests/matrix-02.glsl
ests/matrix-03.glsl
ests/matrix-04.glsl
ests/matrix-05.glsl
ests/matrix-06.glsl
ests/matrix-07.glsl
ests/matrix-08.glsl
ests/matrix-09.glsl
ests/matrix-10.glsl
ests/parameters-01.glsl
ests/parameters-02.glsl
ests/parameters-03.glsl
ests/qualifier-01.glsl
ests/qualifier-02.glsl
ests/qualifier-03.glsl
ests/qualifier-04.glsl
ests/qualifier-05.glsl
ests/qualifier-06.glsl
ests/qualifier-07.glsl
ests/swiz-01.glsl
ests/swiz-02.glsl
ests/void-01.glsl
a663a6371850da64cab33ed8dc5892e3bff06294 04-Jun-2010 Kristian Høgsberg <krh@bitplanet.net> glsl: Recject rect samplers when GL_ARB_texture_rectangle is disabled
l/sl_cl_parse.c
1f2b495b5567897acbd236f302a1e2b9b5faec65 26-Feb-2010 Brian Paul <brianp@vmware.com> glsl: implement support for GL_EXT_texture_array

GL_EXT_texture_array is different from the existing GL_MESA_texture_array
support in that the former is only supported for GLSL, not fixed-function.

The shadow compare versions of the sampler functions haven't been tested
yet. The non-shadow versions have been tested with a new piglit test.
l/sl_cl_parse.c
83a5b7e4689dcc36789f567847ccf65db858a9f3 23-Feb-2010 Vinson Lee <vlee@vmware.com> glsl/apps: Assert that ftell does not return an error.
pps/compile.c
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
d1aafb33b5193db351ece5887edad1c908cbf36b 21-Feb-2010 Vinson Lee <vlee@vmware.com> glsl/cl: Prevent possible buffer overflow.
l/sl_cl_parse.c
ae41339d4ce7c642c03a8d6f5310a68422261150 21-Feb-2010 Vinson Lee <vlee@vmware.com> glsl/cl: Prevent possible string overflow.
l/sl_cl_parse.c
5b392ff49ab6be3947b457feafdbb72463fd0686 17-Feb-2010 Brian Paul <brianp@vmware.com> glsl/apps: print usage info if insufficient args
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
cb66e9f2b427afeffc0b92801e6943f0b17bf1f1 17-Feb-2010 Michal Krol <michal@vmware.com> glsl/pp: Remove sl_pp_get_extension_state().

Parse extension tokens to track current state of extension enables.
p/sl_pp_context.h
p/sl_pp_extension.c
p/sl_pp_public.h
27a68bd14aea55ee4653520403c29e3e16f55e63 17-Feb-2010 Michal Krol <michal@vmware.com> glsl/cl: Parse layout qualifiers only when an appropriate extension enabled.
l/sl_cl_parse.c
a21215a74e56a8661e6191ec09d1be9c0a186111 17-Feb-2010 Michal Krol <michal@vmware.com> glsl/cl: Properly emit layout qualifier list.
l/sl_cl_parse.c
de5928a61549a6ca66e6b9ff6e50b305f653888c 16-Feb-2010 Brian Paul <brianp@vmware.com> sl/pp: re-do extension testing code

The #extension directive should not effect which extension preprocessor
symbols are defined/undefined; only whether/how the compiler accepts
language features defined by the extension.
p/sl_pp_context.h
p/sl_pp_extension.c
p/sl_pp_if.c
p/sl_pp_public.h
fa8acb052839da3b9e77e58ad17d94190f4d2f24 16-Feb-2010 Michal Krol <michal@vmware.com> glsl/pp: Do not try to enable extension `all'.
p/sl_pp_extension.c
ee67167358e91e9ffde8aa9e5b96e5def4c16904 15-Feb-2010 Michal Krol <michal@vmware.com> glsl/pp: Fix handling of if/elif/else cases.

Once if/elif evalutes to true, all subsequent conditions are always false.
p/sl_pp_context.h
p/sl_pp_if.c
f0e1499805eb98e4d6dfe4f95f601593c65044d6 15-Feb-2010 Vinson Lee <vlee@vmware.com> glsl/pp: Add asserts to check for null pointer deferences.
p/sl_pp_extension.c
p/sl_pp_process.c
46f788c2e51630915e5a8cef074daeff8f7fc8cc 13-Feb-2010 Brian Paul <brianp@vmware.com> glsl/cl: implement parsing for layout qualifiers

For GL_ARB_fragment_coord_conventions support.
l/sl_cl_parse.c
3b53b7e8b06d4caa4bebcc0d58ec0a0233ac77ba 13-Feb-2010 Brian Paul <brianp@vmware.com> glsl/pp: fix incorrect extension enable flag for warn mode
p/sl_pp_extension.c
3251f31d593129e772475f2219771c660c53bf4e 10-Feb-2010 Brian Paul <brianp@vmware.com> glsl/pp: fix extension enable/disable options

Now the #extension name: disable/enable flags do the right thing.

Fixes glean/glsl1 "Preprocessor test (extension test 3)"
p/sl_pp_context.h
p/sl_pp_extension.c
p/sl_pp_if.c
8b1c332a77555b94f5665517e5fdcb416e1a67b7 10-Feb-2010 Michal Krol <michal@vmware.com> Simplify GLSL extension mechanism.

Since extension name and extension name string are the same, collapse
them into one name.
pps/compile.c
pps/process.c
p/sl_pp_context.h
p/sl_pp_extension.c
p/sl_pp_public.h
c1395a71ac5f279edca933a325e32e1512e0046b 10-Feb-2010 Michal Krol <michal@vmware.com> glsl/pp: Fix ifdef directive for extension names.
p/sl_pp_if.c
c73dbce8916ecff36f09d957046c6218a8ac5861 26-Jan-2010 Vinson Lee <vlee@vmware.com> glsl/pp: Silence GCC "no previous prototype" warning.
p/sl_pp_purify.c
4c041fac96303200f84b379829fd2f72cbc46423 18-Jan-2010 Brian Paul <brianp@vmware.com> glsl: remove __inline directive

It makes no difference with gcc -O3, for example.
l/sl_cl_parse.c
cbb23523a80615c075d73e4a9b2a1e6ecd135d58 31-Dec-2009 José Fonseca <jfonseca@vmware.com> glsl: Ignore programs.
pps/.gitignore
561a107df71aace22a15003cc77dd504ab8b06a0 29-Dec-2009 Brian Paul <brianp@vmware.com> glsl: added default case in _fetch_token() to silence warnings
l/sl_cl_parse.c
7abdaf574a31f4f09b20a6bc59bdb1bbebf9b15b 28-Dec-2009 José Fonseca <jfonseca@vmware.com> scons: Fix xlib build.

After glsl rework merge.
Conscript
b2a615e3cdd0b48f985a9405cd90bdb3e841eeef 23-Dec-2009 Keith Whitwell <keithw@vmware.com> glsl/pp: move static functions out of header file
Conscript
p/Makefile
p/sl_pp_token_util.c
p/sl_pp_token_util.h
cdd25ab8cfa407d85f9efd78c97aa575aee94d28 23-Dec-2009 Keith Whitwell <keithw@vmware.com> glsl/pp: quieten compiler about missing case statements
p/sl_pp_process.c
55c43ee3158e5e83dcf51a7d6eaa35d4314c0833 21-Dec-2009 Dave Airlie <airlied@redhat.com> glsl: make stack compile.

it would be nice if this stuff would be test built on mesa's primary
platform with mesa's primary build system.

Signed-off-by: Dave Airlie <airlied@redhat.com>
p/sl_pp_macro.h
1071ad70f54aa31fcf96b3adc3911087854ab424 20-Dec-2009 Michal Krol <michal@vmware.com> glsl/apps: Update after glsl cl interface changes.
pps/compile.c
d801c296c602d04055b02b3be2f1369bfe1092b7 20-Dec-2009 Michal Krol <michal@vmware.com> glsl: Do syntax parsing inline with processing.
l/sl_cl_parse.c
l/sl_cl_parse.h
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_define.c
p/sl_pp_error.c
p/sl_pp_extension.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_pragma.c
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_public.h
9c15948125109d6eda7da25a2749680b830e8b82 20-Dec-2009 Michal Krol <michal@vmware.com> glsl/apps: Update after glsl pp interface changes.
pps/process.c
pps/tokenise.c
e0f57a37b2533a92359942a9698427922883d227 20-Dec-2009 Michal Krol <michal@vmware.com> glsl/apps: Do not print number of eaten tokens in version.

This is due to the glsl pp interface changes.
pps/version.c
0874ce48a68c06d8bb7387e434af7471d6638e80 20-Dec-2009 Michal Krol <michal@vmware.com> glsl/apps: Print error line number in compile.
pps/compile.c
d696cb279d80ccddebcb28ef6b6284bc6bb9430f 20-Dec-2009 Michal Krol <michal@vmware.com> glsl/pp: Do processing inline with tokenisation.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_public.h
p/sl_pp_token.c
p/sl_pp_token.h
p/sl_pp_token_util.h
p/sl_pp_version.c
7631dca25bd390901036b48709e243db961d3a1f 19-Dec-2009 Michal Krol <michal@vmware.com> glsl/pp: Remove outdated TODO.

Already implemented in mesa compiler using predefined symbols.
p/sl_pp_macro.c
e9aa65d2b751f81fecd365fd6a550562417a3ec2 19-Dec-2009 Michal Krol <michal@vmware.com> glsl/pp: Report correct error line for purify and tokeniser errors.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_public.h
p/sl_pp_token.c
294bd53d4b6b15a6890599c46f14b205a3c738bf 17-Dec-2009 Sedat Dilek <sedat.dilek@gmail.com> glsl/apps: Add dummy install target to fix 'make install'

Signed-off-by: Brian Paul <brianp@vmware.com>
pps/Makefile
491f384c3958067e6c4c994041f5d8d413b806bc 10-Dec-2009 José Fonseca <jfonseca@vmware.com> scons: Get GLSL code building correctly when cross compiling.

This is quite messy. GLSL code has to be built twice: one for the
host OS, another for the target OS.
Conscript
pps/SConscript
l/SConscript
p/SConscript
289eab5389c0f0f3f85f872b2ba440f5e8416a50 10-Dec-2009 Brian Paul <brianp@vmware.com> glsl/sl: fix _parse_boolconstant()

Need to emit the radix before the digits.
This fixes several glean/glgl1 regressions.
l/sl_cl_parse.c
05eccfe79ec74a04630bcebff4c76accf4f85e0d 10-Dec-2009 Brian Paul <brianp@vmware.com> glsl/apps: remove unused vars
pps/compile.c
pps/process.c
pps/tokenise.c
pps/version.c
0d654a7f2cf173723eee930d2e5b9a1dd0140aaf 10-Dec-2009 Brian Paul <brianp@vmware.com> glsl/pp: make some functions static
p/sl_pp_token.c
52271c5345fedcb5b30736d69e4944889dda234c 10-Dec-2009 Brian Paul <brianp@vmware.com> glsl/pp: declare sl_pp_purify_options to silence warning
p/sl_pp_token.h
7502b6affa72915cadeb0837028e7655e459da69 10-Dec-2009 Brian Paul <brianp@vmware.com> glsl/cl: silence unused var warning
l/sl_cl_parse.c
417f36ccb062bee01aff92d6fcdf47af3ece3cb4 10-Dec-2009 Michal Krol <michal@vmware.com> glsl/apps: Predefine __GLSL_PP_PREDEFINED_MACRO_TEST for testing.
pps/process.c
22200bcafcc77ecdca0127ac72d68e75e2ad7aee 10-Dec-2009 Michal Krol <michal@vmware.com> glsl/pp: Add support for user-defined macros.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_macro.c
p/sl_pp_public.h
d1a09a9ba4a56067cc41e87d00fd7c395f0e7345 10-Dec-2009 Michal Krol <michal@vmware.com> glsl/apps: Explicitly add ARB_draw_buffers and ARB_texture_rectangle.
pps/compile.c
pps/process.c
91e164b3d0b1d36bfdf369266ae7e1ab396f1ba2 10-Dec-2009 Michal Krol <michal@vmware.com> glsl/pp: Add sl_pp_context_add_extension().

This way third parties are able to add supported extension strings.
p/sl_pp_context.h
p/sl_pp_dict.c
p/sl_pp_dict.h
p/sl_pp_extension.c
p/sl_pp_macro.c
p/sl_pp_public.h
068596c9a7e8d330ffdff8ad8700bd6093b5bdea 10-Dec-2009 michal <michal@transistor.(none)> Build mesa glsl with make.

Still don't know how to add glsl to mesa dependencies.
akefile
akefile.template
pps/Makefile
l/Makefile
p/Makefile
77a0a3e5ca5dfa951056d9054b4147e3ea0965f3 25-Nov-2009 Michal Krol <michal@vmware.com> glsl/apps: Make compile more shell friendly.
pps/compile.c
3371f7e5025e5288eaba78973a2c81ec5d5b1e4d 25-Nov-2009 Michal Krol <michal@vmware.com> scons: Autogenerate GLSL builtin library *_gc.h from *.gc files.
pps/SConscript
6199a0cf89034ab92ac61158a25902acc17604f4 21-Nov-2009 Michal Krol <michal@vmware.com> glsl/apps: No need to purify source text for tokeniser.
pps/compile.c
pps/process.c
pps/tokenise.c
pps/version.c
abe1f332983e5c70d75b5ae83f06c0dfdd081a26 21-Nov-2009 Michal Krol <michal@vmware.com> glsl/pp: Do purification and tokenisation in a single step.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_dict.c
p/sl_pp_public.h
p/sl_pp_token.c
p/sl_pp_token.h
b89cd8afc510541a18f2f5c04884637626e104e1 20-Nov-2009 Michal Krol <michal@vmware.com> glsl/pp: Expand unknown identifiers to 0 in if/elif expressions.
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
547ac2869b1e1bbdbf8e51cd40d50e6ab0f4f9f1 17-Nov-2009 Michal Krol <michal@vmware.com> glsl/pp: Fix macro formal argument parsing, more descriptive error msgs.
p/sl_pp_define.c
eaa34c2deac093fc23e2beed9c5580e57289b1e2 13-Nov-2009 Michal Krol <michal@vmware.com> glsl/apps: Report syntax parser errors.
pps/compile.c
99c89ebdb00ff0452f4b106cd53ec4a2e5162137 13-Nov-2009 Michal Krol <michal@vmware.com> glsl/cl: Add simple error reporting.
l/sl_cl_parse.c
l/sl_cl_parse.h
38a1f0b5d1062f8051ac6bb4e3c35fbbf4615163 13-Nov-2009 Michal Krol <michal@vmware.com> glsl/apps: Add GLSL compiler that translates source text into binary stream.

Should be used in place of gc_to_bin utility to precompile builtin library.
pps/SConscript
pps/compile.c
08e90bdea1e4828abfdff6fedfe9e669bfee9ff1 13-Nov-2009 Michal Krol <michal@vmware.com> glsl/cl: Add a hard-coded syntax parser.
l/SConscript
l/sl_cl_parse.c
l/sl_cl_parse.h
d44cebd1ee7b3e461e264150a28c9d49a0f69f8f 10-Nov-2009 Michal Krol <michal@vmware.com> glsl/pp: Add sl_pp_purify_getc().
p/sl_pp_purify.c
p/sl_pp_purify.h
b5c8c87eab4cbc4f05cbd98d7647b9b83607f976 10-Nov-2009 Michal Krol <michal@vmware.com> glsl/apps: Update for glsl/pp interface changes.
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
d37f7694b60d3dad8daf9e2af4e509c15b996553 10-Nov-2009 Michal Krol <michal@vmware.com> glsl/pp: Have sl_pp_purify() return error msg/line no.
p/sl_pp_purify.c
p/sl_pp_purify.h
c4bd6ccde8241d6a5eb631c713ba79db51163701 28-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Expand macro actual arguments before pasting into its body.
p/sl_pp_macro.c
92e33569f39a2fa9061a0c35c233c1db33820033 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add forward decls to silence gcc warnings.
p/sl_pp_macro.h
p/sl_pp_token.h
69fec23251740c3071ffc3fefc8981599bdb22ef 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Avoid using `__VERSION__' as an identifier.
p/sl_pp_dict.c
p/sl_pp_dict.h
p/sl_pp_macro.c
7a95a3c7c4ba49ec174681c36951e3c0672df06c 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Include missing headers.
p/sl_pp_context.c
p/sl_pp_error.c
p/sl_pp_expression.c
p/sl_pp_extension.c
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_pragma.c
p/sl_pp_process.c
p/sl_pp_token.c
p/sl_pp_version.c
e1eed5670246e08119ed7e4afa5313e7717b8128 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Allow builds on all platforms.
p/SConscript
e8e3fe15e1b0f75c43e197f8875a7fae1468f584 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Include missing header, properly escape format strings.
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
db097a9a3ff532d37875b8cd911dda0515a60dcd 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Allow builds on all platforms.
pps/SConscript
a58360dbc2ee1ef919ecd50bd46cb57a151b8550 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Use struct instead of union.
p/sl_pp_token.h
13f9a39cea81bf8f1efd4aca1467c63a49a42dab 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Fix apps after pp interface changes.
pps/process.c
9a1447d449209635e481c7f9bd02084864e17419 24-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Store both line number and file index in a single token.
p/sl_pp_line.c
p/sl_pp_process.c
p/sl_pp_token.h
1ed1dc8b4197ef5a6b0b1fab6ef0694f379642d8 23-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Include missing headers.
p/sl_pp_error.c
p/sl_pp_expression.c
2f89e1a5a18c4c3c88d4e7613cbfc0f85a5fcfc9 23-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add `0' and `1' to dictionary.
p/sl_pp_dict.c
p/sl_pp_dict.h
p/sl_pp_if.c
32966991c629fa43818f42912deb9deca913ef60 23-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Check for reserved macro names.
p/sl_pp_define.c
125691dda3d261d3115bf85265428e28d2bbf6c8 22-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Update after recent pp interface changes.
pps/process.c
pps/tokenise.c
0481e85af7195e13c30580afba233a80feeee740 22-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Differentiate between integer and floating-point number tokens.
p/sl_pp_error.c
p/sl_pp_expression.c
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_token.c
p/sl_pp_token.h
p/sl_pp_version.c
5f9f30a75268bf6803627930ce982aede2c870f5 18-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Use glsl pp public interface.
pps/process.c
pps/purify.c
pps/tokenise.c
pps/version.c
95956bb8cb9513c429b9749426720be94f4cf5a8 18-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Define a public interface for external modules.

Make sl_pp_context struct opaque.
Move all public declarations to sl_pp_public.h.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_line.c
p/sl_pp_process.h
p/sl_pp_public.h
p/sl_pp_token.c
p/sl_pp_token.h
p/sl_pp_version.c
p/sl_pp_version.h
90daefd1c474a6e0502df5053b581987c12b8673 17-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add a TODO for FEATURE_es2_glsl.
p/sl_pp_macro.c
4fcda5000eed29b7c2ba70506ae34b209239eec6 17-Sep-2009 Michal Krol <michal@vmware.com> slang/pp: Fix file number parsing.
p/sl_pp_line.c
ce8f486156f5c4b28b51954ea862675275c38f6d 17-Sep-2009 Michal Krol <michal@vmware.com> slang/pp: Use a dictionary for the remaining string literals.
p/sl_pp_dict.c
p/sl_pp_dict.h
p/sl_pp_if.c
p/sl_pp_macro.c
p/sl_pp_pragma.c
p/sl_pp_process.c
p/sl_pp_version.c
0ddf41d34d511b339e0bb5a59673765f1bf0b3a5 17-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add remaining error messages.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_define.c
p/sl_pp_expression.c
p/sl_pp_if.c
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_pragma.c
p/sl_pp_version.c
69bdd47dba1f7331a632316e4f9cc9942fb93ca4 17-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Always write out error condition.
pps/purify.c
pps/tokenise.c
pps/version.c
cc629940d4a47c998d0ed5dbcc0f396025932e0e 16-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Always write out error condition.
pps/process.c
a7382628f2ed5a2886a1828dd847d75bf8e9b38e 16-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Validate numbers.
p/sl_pp_token.c
de0753e4cb64792d257ad3799932a77321fc3c49 16-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add more error messages.
p/sl_pp_token.c
d4638f5dce4cb2c873acafb289036fd59c7a3c78 16-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add more error messages.
p/sl_pp_process.c
0f302b60fd6d43a47e208979d0677e09f4a802fc 14-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Support GL_ARB_draw_buffers and GL_ARB_texture_rectangle.
p/sl_pp_extension.c
169aead1b55446c7bfe669b6a822d56e8af15f7f 14-Sep-2009 Michal Krol <michal@vmware.com> glsl/apps: Adapt to pp interface change.
pps/process.c
pps/tokenise.c
pps/version.c
a67f32289a6e22daa2665310f4a8f26979f7ed60 14-Sep-2009 Michal Krol <michal@vmware.com> glsl/pp: Add a dictionary to a context.
p/SConscript
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_dict.c
p/sl_pp_dict.h
5ad89377522061775b467d84bf6dc14305cccfbf 07-Sep-2009 Michal Krol <michal@vmware.com> glsl: Add error messages for version parser.
p/sl_pp_version.c
b7960b3d3ac347604bfec705a50d6c2eda439eef 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Handle file tokens in apps/process.
pps/process.c
a64ba93aab6de7ee2ceb70f39cf2dbe794940c97 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Handle file numbering.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_token.h
2d2d6384448baae3c04eced3373d96907def4e13 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Actually respect the hash-line directive.
p/sl_pp_line.c
b6df77fb9a6093eb8ed13b5c7c1327c162c41584 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Handle line tokens in apps/process.
pps/process.c
4aa3222df315e3b36c73374e9000a6607c3b995c 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Correctly handle line numbering.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_line.c
p/sl_pp_macro.c
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_token.h
p/sl_pp_version.c
0d9c5eafeb35fdd2e5009ba0b397d1acdfbd3205 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Preserve newline inside comment blocks.
p/sl_pp_purify.c
e8afc6558909d9503a83c8cc184a2e2bb008746b 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Implement predefinded macros.

The values are hardcoded: __LINE__ = 1, __FILE__ = 0 and __VERSION__ = 110.
p/sl_pp_macro.c
bb8f38ea6f71179cd4adb0ca33c464716be17dcb 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Implement `line' preprocessor directive.
p/SConscript
p/sl_pp_line.c
p/sl_pp_process.c
p/sl_pp_process.h
ddd8ae7fbc643892b08ddf66c67bca36d42b53a6 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Output endof token after processing a directive.

Some directives may output tokens as a result of their operation.
p/sl_pp_process.c
7f187583c14448047c95d933a96b190273a881e5 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Handle extension tokens in apps/proces.
pps/process.c
87d2de04fbb7d9ea8eae9c58f7c7fb842ffe06f6 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Implement `extension' preprocessor directive.

No extensions supported.
p/SConscript
p/sl_pp_extension.c
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_token.h
94321b44416f47eb08bf72c93f4299ff7dc47017 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Handle pragma tokens in apps/process.
pps/process.c
0e046420e468bcb81301aa5a5e4de736a8b4844a 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Implement `pragma' preprocessor directive.

Handle `optimize(on|off)' and `debug(on|off)' pragmas.
p/SConscript
p/sl_pp_pragma.c
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_token.h
c42428c787aae4bc560adf507991f1e274407135 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Print out error message in apps/process.
pps/process.c
f9bd6f7152047e6230c85d76e412a5bb524e0413 04-Sep-2009 Michal Krol <michal@vmware.com> glsl: Implement `error' preprocessor directive.
p/SConscript
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_error.c
p/sl_pp_process.c
p/sl_pp_process.h
3dc2b5f71c2a519409becb6c1f177b5981fbacf7 26-Jun-2009 Michal Krol <michal@vmware.com> glsl: Implement `undef' preprocessor directive.
p/sl_pp_define.c
p/sl_pp_process.c
p/sl_pp_process.h
a294715612d14d64e12026361ff7cc29321607d6 26-Jun-2009 Michal Krol <michal@vmware.com> glsl: Allow for preprocessor macro redefinition.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_define.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
p/sl_pp_process.h
153b179862411e9de14d26bbcff16bc81f1edc91 26-Jun-2009 Michal Krol <michal@vmware.com> glsl: Handle `defined' preprocessor operator.
p/sl_pp_if.c
3b027bca9d54383b2fc8b2ad5a9cb6d2166c7acc 26-Jun-2009 Michal Krol <michal@vmware.com> glsl: Support if preprocessor directive and friends.
p/SConscript
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_if.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
p/sl_pp_process.h
3bb446ba6e890bc3f60a34318a5a0fe860e53cbb 26-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add expression interpreter.
p/SConscript
p/sl_pp_expression.c
p/sl_pp_expression.h
2dad8ed9d68289ba25a4023da12fc5ddf6a621dd 22-Jun-2009 Michal Krol <michal@vmware.com> glsl: Centralise sl_pp_macro constructor.
p/sl_pp_define.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
6a11d4150cfcdd646c17f8b365b5481c2c583208 22-Jun-2009 Michal Krol <michal@vmware.com> glsl: Implement macro expansion.
p/sl_pp_define.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
p/sl_pp_process.h
5e8e3cddae9b2797cfa525c643c701debe2f4c04 21-Jun-2009 Michal Krol <michal@vmware.com> glsl: Rename sl_pp_context_add_str to sl_pp_context_add_unique_str.

Return the same offset for same strings. Allows to compare strings
by comparing their's offsets.
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_token.c
p/sl_pp_token.h
fd991d845a5f639b9b675a4840ad234c151d56b4 19-Jun-2009 Michal Krol <michal@vmware.com> glsl: Parse define directive in preprocessor.
p/SConscript
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_define.c
p/sl_pp_macro.c
p/sl_pp_macro.h
p/sl_pp_process.c
p/sl_pp_process.h
3ce5e668180748e2eccd1a8d3931ab98c2919df3 17-Jun-2009 Michal Krol <michal@vmware.com> glsl: Simplify directive parser skeleton.
p/sl_pp_context.h
p/sl_pp_process.c
p/sl_pp_process.h
f24322fbf6599b31f07ebc548e390c77b803d67c 17-Jun-2009 Michal Krol <michal@vmware.com> glsl: Introduce sl_pp_context and maintain a reuseable pool of strings.
pps/process.c
pps/tokenise.c
pps/version.c
p/SConscript
p/sl_pp_context.c
p/sl_pp_context.h
p/sl_pp_process.c
p/sl_pp_process.h
p/sl_pp_token.c
p/sl_pp_token.h
p/sl_pp_version.c
p/sl_pp_version.h
f24ec185c531d2b2209df01901c90eca57ca711f 15-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add `process' test app that returns tokenised and preprocessed text.
pps/SConscript
pps/process.c
9d336c5264d59e455380a305ee99675e2219ae06 15-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add preprocessor skeleton for directive parsing.
p/SConscript
p/sl_pp_process.c
p/sl_pp_process.h
5d26deef981d201573252125a8a106b87f66a73c 15-Jun-2009 Michal Krol <michal@vmware.com> glsl: Remove bogus sl_pp_directive.h include.
p/sl_pp_token.c
b4e92367f33c8bdd14337ced63abe82685f08cb3 15-Jun-2009 Michal Krol <michal@vmware.com> glsl: Allow for multiple version statements.
p/sl_pp_version.c
55f75c13f05ea6373b95f0777078fcdec226672a 13-Jun-2009 Michal Krol <michal@vmware.com> glsl/apps: Print out the number of tokens eaten in version test.
pps/version.c
474f754282c06014fa0f687c08f4e97323166f83 13-Jun-2009 Michal Krol <michal@vmware.com> glsl: Raise an error on an unfinished comment block.
p/sl_pp_purify.c
af617c603720cf41ec433f1653cc6dbdcffd8e31 13-Jun-2009 Michal Krol <michal@vmware.com> glsl/apps: Add version test app.
pps/SConscript
pps/version.c
229e72956ca6844647bd64d864716b8e21aff89b 13-Jun-2009 Michal Krol <michal@vmware.com> glsl: Parse optional version directive.
p/SConscript
p/sl_pp_version.c
p/sl_pp_version.h
0d5ef796f847bc51888a8883110cc607494a61f0 12-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add a tokenise app.
pps/SConscript
pps/tokenise.c
2c9a627b48119b3cafc9fb25239fe929bc4cf8d8 12-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add a preprocessor tokeniser.
p/SConscript
p/sl_pp_token.c
p/sl_pp_token.h
121769eeb314ea580a3292309332ebbf0a409b3c 11-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add a purify command-line tool.
pps/SConscript
pps/purify.c
p/SConscript
0bbf59c3052a7b4f6f8330985317adce2bfd0fef 11-Jun-2009 Michal Krol <michal@vmware.com> glsl: Add preprocessor purifier.
p/SConscript
p/sl_pp_purify.c
p/sl_pp_purify.h