summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/glcpp-parse.y
Commit message (Collapse)AuthorAgeFilesLines
* glsl: add support for ARB_texture_multisampleChris Forbes2013-03-021-0/+3
| | | | | | | | | | | | | | | | | | V2: - emit `sample` parameter properly for multisample texelFetch() - fix spurious whitespace change - introduce a new opcode ir_txf_ms rather than overloading the existing ir_txf further. This makes doing the right thing in the driver somewhat simpler. V3: - fix weird whitespace V4: - don't forget to include the new opcode in tex_opcode_strs[] (thanks Kenneth for spotting this) Signed-off-by: Chris Forbes <[email protected]> [V2] Reviewed-by: Eric Anholt <[email protected]> [V2] Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add infrastructure for ARB_shading_language_packingMatt Turner2013-01-251-0/+3
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glcpp: Make undefined macros illegal in #if and #elif for GLES3Carl Worth2013-01-111-0/+2
| | | | | | | | | | | | Simply emitting a nicely-formatted error message if any undefined macro is encountered in a parser context expecting an expression. With this commit, the following piglit test now passes: spec/glsl-es-3.00/compiler/undefined-macro.vert Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add a flag to the parser state to indicate GLES.Carl Worth2013-01-111-11/+15
| | | | | | | | | | | | This can be triggered either by creation of a GLES context (with api == API_OPENGLES2) or else by a #version directive with version value 100 or with a string of "es" following the version value. There's no behavioral change with this commit—just preparation for ES-specific behavior in the preprocessor in the future. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/preprocessor: Handle "#version 300 es" directive.Paul Berry2012-12-061-4/+17
| | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/preprocessor: Extract version directive processing into a function.Paul Berry2012-12-061-19/+30
| | | | | | | | | | | | | | | | | | | | | Version directive handling is going to have to be used within two parser rules, one for desktop-style version directives (e.g. "#version 130") and one for the new ES-style version directive (e.g. "#version 300 es"), so this patch moves it to a function that can be called from both rules. No functional change. [mattst88] v2: Use intmax_t instead of int for version argument. Would otherwise write garbage after #version since PRIiMAX was reading 64-bits instead of 32. [idr] v3: A later commit fixes the caller of _glcpp_parser_handle_version_declaration to pass the correct number of parameters. Fix it in the patch that changes the interface instead. Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glcpp: Add support for pasting of INTEGER tokens.Carl Worth2012-11-291-14/+47
| | | | | | | By generalizing the current code designed to paste string tokens of various types. Reviewed-by: Matt Turner <[email protected]>
* glcpp: Flag invalid pastes for integer followed by non-digitsCarl Worth2012-11-291-5/+13
| | | | | | | | | As recently tested in the additions to the invalid paste test, it is illegal to paste a non-digit sequence onto the end of an integer. The 082-invalid-paste test should now pass again. Reviewed-by: Matt Turner <[email protected]>
* glcpp: More factoring-out of common code to simplify things.Carl Worth2012-11-291-26/+20
| | | | | | | | This time creating a new _token_list_create_with_one_integer function modeled after the existing _token_list_create_with_one_space function (both implemented with new _token_list_create_with_one_ival). Reviewed-by: Matt Turner <[email protected]>
* glcpp: Factor out a tiny bit of repeated code.Carl Worth2012-11-291-4/+1
| | | | | | | This function is getting a little long too read. Simplify it by pulling up one assignment from every condition. Reviewed-by: Matt Turner <[email protected]>
* glcpp: Add support for __LINE__ and __FILE__ macrosCarl Worth2012-11-291-1/+30
| | | | | | | | | | | | | These tokens are easy to expand by just looking at the current, tracked location values, (and no need to look anything up in the hash table). Add a test which verifies __LINE__ with several values, (and verifies __FILE__ for the single value of 0). Our testing framework isn't sophisticated enough here to have a test with multiple file inputs. This commit fixes part of es3conform's preprocess16_frag test. Reviewed-by: Matt Turner <[email protected]>
* glcpp: Don't define macros for extensions that aren't in ESMatt Turner2012-11-151-28/+31
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: don't push #line directives into next lineFabian Bieler2012-11-091-8/+8
| | | | | | | | | | | | | | By moving the HASH_LINE rule out of control_line: and into line:, we avoid adding control_line's additional \n (as seen in the first hunk). mattst88: Carl and I determined independently of Fabian that the 091 test needed to be modified identically to this, and our patch to fix the test was more complicated. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51506 Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Reject garbage after #else and #endif tokensMatt Turner2012-11-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> (glcpp-parse.y) Acked-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add ARB_texture_cube_map_array support (v2)Dave Airlie2012-11-091-0/+3
| | | | | | | | | | | | This adds all the new builtins + the new sampler types, and hooks them up if the extension is supported. v2: fix missing signatures for grad/lod fix missing textureSize clarifications fix compare vs starts with usage Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glcpp: Don't use infinite lookhead for #define differentiation.Kenneth Graunke2012-10-251-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Carl Worth <[email protected]>
* glcpp: fix abuse of yylexDave Airlie2012-09-151-8/+0
| | | | | | | | | | | | 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]>
* 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]>
* 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: Move handling of #line directives from lexer to parser.Carl Worth2012-06-261-1/+32
| | | | | | | | | | | | | | | | | | | 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: glcpp: Allow "#if undefined-macro' to evaluate to false.Carl Worth2012-06-261-0/+3
| | | | | | | | | | | | | | | | | 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]>
* 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]>
* glcpp: Don't strlen() the output for every token being printed.Kenneth Graunke2012-02-281-24/+26
| | | | | | | | | | | | | 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.
* 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: Raise error if defining any macro containing two consecutive underscoresCarl Worth2011-09-301-2/+2
| | | | | | | | | | | | | | | | | | 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: 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 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]>
* 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: Raise error when modulus is zeroChad Versace2011-02-021-1/+6
| | | | | | | | | | 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.
* glsl: make _token_list_is_empty_ignoring_space() staticBrian Paul2011-01-311-1/+1
| | | | To silence warning about missing prototype.
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-75/+76
|
* Revert "glcpp: Demote "macro redefined" from an error to a warning"Carl Worth2011-01-291-4/+4
| | | | | | | | 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).
* glcpp: Demote "macro redefined" from an error to a warningCarl Worth2011-01-281-4/+4
| | | | | | | | | | 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.
* glcpp: Conditionally define macro GL_AMD_conservative_depthChad Versace2011-01-261-0/+2
| | | | | Define macro GL_AMD_conservative_depth to 1 when its extension is enabled.
* glcpp: Remove use of talloc reference counting.Kenneth Graunke2011-01-211-13/+7
| | | | | 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).
* glcpp: Generate an error for division by zeroIan Romanick2011-01-101-1/+6
| | | | | | | | | | | | | | | | | | | | 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.
* glcpp: Fix segfault when validating macro redefinitionsChad Versace2011-01-101-0/+21
| | | | | | | | 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.
* glcpp: Don't emit SPACE tokens in conditional_tokens production.Kenneth Graunke2010-12-071-1/+0
| | | | | | | | Fixes glslparsertest defined-01.vert. Reported-by: José Fonseca <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.Kenneth Graunke2010-11-171-1/+6
| | | | | | | | | 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.
* glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version >= 1.30.Kenneth Graunke2010-11-161-0/+3
| | | | Per section 4.5.4 of the GLSL 1.30 specification.
* glcpp: Add the define for ARB_explicit_attrib_location when presentIan Romanick2010-10-081-0/+3
|
* glcpp: Fix build on non-GCC compilers.Kenneth Graunke2010-09-071-3/+4
|
* glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.Kenneth Graunke2010-09-071-1/+8
| | | | Also define it if #version 100 is encountered.