summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa/glsl: rename preprocess to glcpp_preprocessDave Airlie2012-09-153-3/+3
| | | | | | | | | | 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 <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glcpp: fix abuse of yylexDave Airlie2012-09-152-9/+1
| | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* build/glsl: fix location of generated files.Christopher James Halse Rogers2012-08-131-4/+0
| | | | | | | | Like in src/mesa, use GLSL_BUILDDIR/GLSL_SRCDIR to unambiguously distinguish between in-tree and generated files. Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Christopher James Halse Rogers <[email protected]>
* glcpp: Add a newline to expanded #line directives.Kenneth Graunke2012-07-281-2/+2
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* automake: convert libglslJon TURNEY2012-07-132-0/+58
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Matt Turner <[email protected]>
* glcpp: Add built-in #define for GL_ARB_uniform_buffer_object.Kenneth Graunke2012-07-091-0/+3
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: glcpp: Extend testing of #line directivesCarl Worth2012-06-262-0/+12
| | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: glcpp: Move handling of #line directives from lexer to parser.Carl Worth2012-06-264-40/+55
| | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: glcpp: Rename and document _glcpp_parser_expand_ifCarl Worth2012-06-261-5/+20
| | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Consistently use length-based ralloc string functions for info_log.Carl Worth2012-06-261-14/+24
| | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: glcpp: Allow "#if undefined-macro' to evaluate to false.Carl Worth2012-06-265-3/+20
| | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: .gitignore cleanupAndreas Boll2012-06-081-3/+0
| | | | | | *.o, *.lo and *~ are already in toplevel .gitignore Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Scaffolding for ARB_shader_bit_encoding.Olivier Galibert2012-06-071-0/+3
| | | | | | | | That adds support for activating the extension. It doesn't actually *do* anything yet, of course. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* Add .deps/, .libs/, and *.la to toplevel .gitignorePaul Berry2012-03-201-2/+0
| | | | | | | To avoid redundancies, this patch also removes .deps, .libs, and *.la from .gitignore files in subdirectories. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Don't strlen() the output for every token being printed.Kenneth Graunke2012-02-282-24/+28
| | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v1] Acked-by: José Fonseca <[email protected]> [v1]
* glsl: Avoid ralloc_stealing a long-lived object to a short-lived parentCarl Worth2012-02-021-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> NOTE: This is a candidate for stable release branches.
* glsl: Add glcpp tests for a macro used twiceCarl Worth2012-02-022-0/+33
| | | | | | | | | | | | | 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 <[email protected]>
* glcpp: Fix so that trailing punctuation does not prevent macro expansionCarl Worth2012-02-021-1/+9
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> NOTE: This is a candidate for stable release branches.
* glcpp: Add new test showing bug where a trailing ':' prevents macro expansionCarl Worth2012-02-022-0/+15
| | | | | | | | | | | 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 <[email protected]>
* Revert "automake: src/glsl and src/glsl/glcpp"Matt Turner2012-01-312-47/+0
| | | | This reverts commit 9947656168d09f9019600fccc42ca8e0de49b83a.
* Revert "src/glsl/glcpp: wire up glcpp-test to make check"Matt Turner2012-01-312-7/+1
| | | | This reverts commit 2bb9f9e1fda61fceb9284cbb4619d7e60e39f190.
* src/glsl/glcpp: wire up glcpp-test to make checkMatt Turner2012-01-302-1/+7
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* glcpp-test: don't return failure if valgrind tests aren't runMatt Turner2012-01-301-1/+1
| | | | | | | | | | | | 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 <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* automake: src/glsl and src/glsl/glcppMatt Turner2012-01-302-0/+47
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* mesa: rename the AMD_conservative_depth extension flag to ARBMarek Olšák2011-11-221-1/+1
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add GL_ARB_draw_instanced #define.Morgan Armand2011-11-121-0/+3
|
* glsl: add support for GL_OES_EGL_image_externalChia-I Wu2011-11-031-0/+3
| | | | | | | | | | 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 <[email protected]> Acked-by: Jakob Bornecrantz <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add a test for #elif with an undefined macro.Carl Worth2011-09-302-0/+8
| | | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Carl Worth <[email protected]>
* glcpp: Raise error if defining any macro containing two consecutive underscoresCarl Worth2011-09-303-3/+7
| | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Carl Worth <[email protected]>
* glcpp: Implement token pasting for non-function-like macrosCarl Worth2011-09-301-36/+47
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Carl Worth <[email protected]>
* glcpp: Test a non-function-like macro using the token paste operatorCarl Worth2011-09-302-0/+7
| | | | | | | | 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 <[email protected]> Signed-off-by: Carl Worth <[email protected]>
* glcpp: Fix two (or more) successive applications of token pastingCarl Worth2011-09-301-2/+0
| | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Carl Worth <[email protected]>
* glcpp: Add a test for a macro that implements token pasting twice.Carl Worth2011-09-302-0/+7
| | | | | | | This is something that piglit is exercising that currently fails. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Carl Worth <[email protected]>
* glsl: Silence several "warning: unused parameter"Ian Romanick2011-09-091-0/+1
|
* glcpp: Add GL_ARB_conservative_depth #define.Kenneth Graunke2011-08-251-1/+3
| | | | | | | Forgotten in the patch that enabled the extension. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Add compiler support for ARB_shader_texture_lod.Kenneth Graunke2011-05-091-0/+4
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Tested-by: Marek Olšák <[email protected]>
* glcpp: Fix attempts to expand recursive macros infinitely (bug #32835).Carl Worth2011-04-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-and-tested-by: Kenneth Graunke <[email protected]>
* Add expected file for 095-recursive-define test case.Carl Worth2011-04-141-0/+4
| | | | | | | | | | 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.
* glcpp: Simplify calling convention of parser's active_list functionsCarl Worth2011-04-141-38/+38
| | | | | | | | | | | | 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.
* glcpp: Add --valgrind option to the glcpp-test utilityCarl Worth2011-04-141-16/+46
| | | | | | | | | | | 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.
* Add an expected file for 084-unbalanced-parenthesesCarl Worth2011-04-141-0/+2
| | | | | | | | | | | | 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.
* Add an expected file for 094-divide-by-zero-short-circuitCarl Worth2011-04-142-0/+26
| | | | | | | | | | | 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).
* Add an expected file for 093-divide-by-zeroCarl Worth2011-04-141-0/+4
| | | | | | 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.
* glsl/glcpp: Use stdio.h instead of unistd.h.José Fonseca2011-03-041-25/+15
|
* glsl: Define YY_NO_UNISTD_H on MSVC.José Fonseca2011-03-041-0/+4
|
* glcpp: Remove trailing contexts from #if rules.Kenneth Graunke2011-03-031-6/+6
| | | | These are now unnecessary.
* glcpp: Rework lexer to use a SKIP state rather than REJECT.Kenneth Graunke2011-03-031-21/+16
| | | | | | | | | | | | | | | | | | | 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.
* glcpp/tests: Update 063-comments.c.expected to match output.Kenneth Graunke2011-03-031-0/+7
| | | | | | | 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.
* glsl: Remove unused glcpp/Makefile.am.Kenneth Graunke2011-03-021-44/+0
| | | | This is a remnant of when glsl2 lived in its own repository.
* Add generated parser / lexer files to gitignore listsIan Romanick2011-03-011-0/+3
|