summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Add extension tracking for AMD_shader_trinary_minmaxMaxence Le Doré2014-01-061-0/+3
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: error on multiple #else/#elif directivesErik Faye-Lund2014-01-026-1/+51
| | | | | | | | | | | | | | | | | | | | | The preprocessor currently accepts multiple else/elif-groups per if-section. The GLSL-preprocessor is defined by the C++ specification, which defines the following parse-rule: if-section: if-group elif-groups(opt) else-group(opt) endif-line This clearly only allows a single else-group, that has to come after any elif-groups. So let's modify the code to follow the specification. Add test to prevent regressions. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Carl Worth <[email protected]> Cc: 10.0 <[email protected]>
* glcpp: Replace multi-line comment with a space (even as part of macro ↵Carl Worth2014-01-028-9/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | definition) The preprocessor has always replaced multi-line comments with a single space character, (as required by the specification), but as of commit bd55ba568b301d0f764cd1ca015e84e1ae932c8b the lexer also emitted a NEWLINE token for each newline within the comment, (in order to preserve line numbers). The emitting of NEWLINE tokens within the comment broke the rule of "replace a multi-line comment with a single space" as could be exposed by code like the following: #define FOO a/* */b FOO Prior to commit bd55ba568b301d0f764cd1ca015e84e1ae932c8b, this code defined the macro FOO as "a b" as desired. Since that commit, this code instead defines FOO as "a" and leaves a stray "b" in the output. In this commit, we fix this by not emitting the NEWLINE tokens while lexing the comment, but instead merely counting them in the commented_newlines variable. Then, when the lexer next encounters a non-commented newline it switches to a NEWLINE_CATCHUP state to emit as many NEWLINE tokens as necessary (so that subsequent parsing stages still generate correct line numbers). Of course, it would have been more clear if we could have written a loop to emit all the newlines, but flex conventions prevent that, (we must use "return" for each token we emit). It similarly would have been clear to have a new rule restricted to the <NEWLINE_CATCHUP> state with an action much like the body of this if condition. The problem with that is that this rule must not consume any characters. It might be possible to write a rule that matches a single lookahead of any character, but then we would also need an additional rule to ensure for the <EOF> case where there are no additional characters available for the lookahead to match. Given those considerations, and given that the SKIP-state manipulation already involves a code block at the top of the lexer function, before any rules, it seems best to me to go with the implementation here which adds a similar pre-rule code block for the NEWLINE_CATCHUP. Finally, this commit also changes the expected output of a few, existing glcpp tests. The change here is that the space character resulting from the multi-line comment is now emitted before the newlines corresponding to that comment. (Previously, the newlines were emitted first, and the space character afterward.) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72686 Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add a more descriptive comment for the SKIP state manipulationCarl Worth2014-01-021-5/+36
| | | | | | | | | | | | | | | | | | | Two things make this code confusing: 1. The uncharacteristic manipulation of lexer start state outside of flex rules. 2. The confusing semantics of the skip_stack (including the "lexing_if" override and the SKIP_NO_SKIP state). This new comment is intended to bring a bit more clarity for any readers. There is no intended beahvioral change to the code here. The actual code changes include better indentation to avoid an excessively-long line, and using the more descriptive INITIAL rather than 0. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add infrastructure for GL_ARB_sample_shadingAnuj Phogat2013-11-011-0/+3
| | | | | | | | | | | This patch implements the common support code required for the GL_ARB_sample_shading extension. V2: Move GL_ARB_sample_shading to ARB extension list. Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ken Graunke <[email protected]>
* glsl: Add built-in functions and constants required for ↵Francisco Jerez2013-10-291-0/+3
| | | | | | | | ARB_shader_atomic_counters. v2: Represent atomics as GLSL intrinsics. Reviewed-by: Ian Romanick <[email protected]>
* glsl: add plumbing for GL_ARB_texture_query_levelsChris Forbes2013-10-051-0/+3
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: add texture gather changesMaxence Le Dore2013-10-031-0/+3
| | | | | | | | | | V2 [Chris Forbes]: - Add new pattern, fixup parameter reading. V3: Rebase onto new builtins machinery Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Rename MESA_shader_integer_mix to EXT_shader_integer_mixIan Romanick2013-09-131-2/+2
| | | | | | | | | | | | | | Everyone at the Khronos meeting was as surprised that GLSL didn't already support this as we were. Several vendors said they'd ship it, but there didn't seem to be enough interest to put in the effort to make it ARB or KHR. v2: Fix a couple typos and rename the spec file to EXT_shader_integer_mix.spec. Suggested by Roland. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* glsl: Implement MESA_shader_integer_mix extension.Matt Turner2013-09-091-0/+3
| | | | | | | Because why doesn't GLSL allow you to do this already? Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add infrastructure for ARB_shading_language_420pack.Todd Previte2013-06-141-0/+3
| | | | | | | | v2 [mattst88] - Split infrastructure into separate patch. - Add preprocessor #define. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: fix OES_EGL_image_external being partially allowed in the core profileMarek Olšák2013-06-131-7/+7
| | | | Reviewed-by: Chad Versace <[email protected]>
* glcpp: Automatically #define GL_core_profile 1 on GLSL 1.50+.Kenneth Graunke2013-06-101-0/+3
| | | | | | | | | | Page 17 of the GLSL 1.50.11 specification states: "There is a built-in macro definition for each profile the implementation supports. All implementations provide the following macro: Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glcpp: Add test case for recently fixed loop-control underflow bug.Carl Worth2013-06-032-0/+25
| | | | | | | To trigger the bug, it suffices to have a line-continuation followed by a newline and then a non-line-continuation backslash. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Fix post-decrement underflow in loop-control variableCarl Worth2013-06-031-1/+3
| | | | | | | | | | | | | This loop-control condition with a post-decrement operator would lead to an underflow of collapsed_newlines. This in turn would cause a subsequent execution of the loop to labor inordinately trying to return the loop-control variable to a value of 0 again. Fix this by dis-intertwining the test and the decrement. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65112 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add AMD_vertex_shader_layer supportJordan Justen2013-05-131-0/+3
| | | | | | | | This GLSL extension requires that AMD_vertex_shader_layer be enabled by the driver. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add infrastructure for ARB_gpu_shader5.Matt Turner2013-05-061-0/+3
| | | | Reviewed-by: Chris Forbes <[email protected]>
* glsl: Implement ARB_texture_query_lodDave Airlie2013-03-291-0/+3
| | | | | | | | | | | | | | | | | | | v2 [mattst88]: - Rebase. - #define GL_ARB_texture_query_lod to 1. - Remove comma after ir_lod in ir.h for MSVC. - Handled ir_lod in ir_hv_accept.cpp, ir_rvalue_visitor.cpp, opt_tree_grafting.cpp. - Rename textureQueryLOD to textureQueryLod, see https://www.khronos.org/bugzilla/show_bug.cgi?id=821 - Fix ir_reader of (lod ...). v3 [mattst88]: - Rename textureQueryLod to textureQueryLOD, pending resolution of Khronos 821. - Add ir_lod case to ir_to_mesa.cpp. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* 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]>
* glsl/build: Build glcpp via the glsl MakefileMatt Turner2013-01-222-56/+2
| | | | | | Removing the subdirectory recursion provides a small speed up. Tested-by: Andreas Boll <[email protected]>
* glsl/build: Remove dead LIBRARY_* variablesMatt Turner2013-01-201-2/+0
| | | | Reviewed-by: Andreas Boll <[email protected]>
* glcpp: Add tests for line continuationCarl Worth2013-01-114-0/+46
| | | | | | | | | First we test that line continuations are honored within a comment, (as recently changed in glcpp), then we test that line continuations can be disabled via an option within the context. This is tested via the new support for a test-specific command-line option passed to glcpp. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Rewrite line-continuation support to act globally.Carl Worth2013-01-111-66/+49
| | | | | | | | | | | | | | | | | | | Previously, we were only supporting line-continuation backslash characters within lines of pre-processor directives, (as per the specification). With OpenGL 4.2 and GLES3, line continuations are now supported anywhere within a shader. While changing this, also fix a bug where the preprocessor was ignoring line continuation characters when a line ended in multiple backslash characters. The new code is also more efficient than the old. Previously, we would perform a ralloc copy at each newline. We now perform copies only at each occurrence of a line-continuation. This commit fixes the line-continuation.vert test in piglit. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Add --disable-line-continuations argument to standalone glcppCarl Worth2013-01-111-2/+44
| | | | | | | This will allow testing of disabled line-continuation on a case-by-case basis, (with the option communicated to the preprocessor via the GL context). Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Allow test-specific arguments for standalone glcpp testsCarl Worth2013-01-111-2/+9
| | | | | | | | This will allow the test exercising disabled line continuations to arrange for the --disable-line-continuations argument to be passed to the standalone glcpp. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Honor the GL context's DisableGLSLLineContinuations optionCarl Worth2013-01-111-1/+3
| | | | | | And simply don't call into the function that removes line continuations. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Accept pointer to GL context rather than just the API versionCarl Worth2013-01-113-4/+17
| | | | | | | | | As the preprocessor becomes more sophisticated and gains more optional behavior, it's easiest to just pass the GL context pointer to it so that it can examine any fields there that it needs to (such as API version, or the state of any driconf options, etc.). Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Reject token pasting operator in GLESMatt Turner2013-01-111-0/+2
| | | | | | | | | The GLSL ES 3.0 spec (Section 12.17) says: "GLSL ES 1.00 removed token pasting and other functionality." NOTE: This is a candidate for the stable branches. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[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-112-11/+16
| | | | | | | | | | | | 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]>
* glcpp: Add back tests/*.out to .gitignoreAndreas Boll2013-01-111-0/+1
| | | | Accidentally removed in ac2793cf3e1e004942c386dfa45f3b5507223f50
* Clean up .gitignore filesMatt Turner2013-01-101-2/+0
|
* glcpp: Typo fix.Adam Jackson2013-01-021-1/+1
| | | | | | Note: this is a candidate for the 9.0 stable branch. Signed-off-by: Adam Jackson <[email protected]>
* glcpp: Fix visibility CFLAGS in automakeAdam Jackson2013-01-021-0/+1
| | | | | | Note: this is a candidate for the 9.0 stable branch. Signed-off-by: Adam Jackson <[email protected]>
* program/hash_table.c: rename to program/prog_hash_table.cJordan Justen2012-12-071-1/+1
| | | | | | | | Removes a collision of the object file name for main/hash_table and program/hash_table. Signed-off-by: Jordan Justen <[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]>
* Revert "glcpp: Rewrite line-continuation support to act globally."Carl Worth2012-11-301-43/+66
| | | | | | | | This reverts commit 962a1c07b44fe500b79b3ca6806d72a432c1f055. Further testing revealed that this commit can cause the pre-processor to enter infinite loops. For now, simply revert this code until a cleaner, better-tested version is available.
* glcpp: Rewrite line-continuation support to act globally.Carl Worth2012-11-301-66/+43
| | | | | | | | | | | | | | | | | Previously, we were only supporting line-continuation backslash characters within lines of pre-processor directives, (as per the specification). With OpenGL 4.2 and GLES3, line continuations are now supported anywhere within a shader. While changing this, also fix a bug where the preprocessor was ignoring line continuation characters when a line ended in multiple backslash characters. The new code is also more efficient than the old. Previously, we would perform a ralloc copy at each newline. We now perform copies only at each occurrence of a line-continuation. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Update README for new support of __LINE__ and __FILE__.Carl Worth2012-11-291-3/+1
| | | | | | | | | Drop these from the known limitations list since support was recently added for these. Also, fix a typo while in the area, (and the oddly missing final newline). Reviewed-by: Matt Turner <[email protected]>
* glcpp: Add test involving token pasting of INTEGER tokens.Carl Worth2012-11-292-0/+15
| | | | | | | | | | | | | | | This test file is very similar to test 113-line-and-file-macros but uses token pasting for cleaner quiz answers (without spaces between the digits). This test passes thanks to the recent addition of support for pasting INTEGER tokens, (but would have failed without that). (Note that this test is distinct from test 059-token-pasting-integer which pastes integers parsed from the source. Those are parsed to INTEGER_STRING tokens and are already pasted correctly as verified by that test. The only way to generate the INTEGER tokens which currently fail to paste is with an internal define such as __LINE__ that results in an integer.) Reviewed-by: Matt Turner <[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: Extend the invalid-paste testCarl Worth2012-11-292-0/+20
| | | | | | | | The current code lets a few invalid pastes through, such as an string pasted onto the end of an integer. Extend the invalid-paste test to catch some of these. 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-293-1/+45
| | | | | | | | | | | | | 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]>
* mesa: Rename API_OPENGL to API_OPENGL_COMPAT.Paul Berry2012-11-291-1/+1
| | | | | | | | | | This should help avoid confusion now that we're using the gl_api enum to distinguishing between core and compatibility API's. The corresponding enum value for core API's is API_OPENGL_CORE. Acked-by: Eric Anholt <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
* glcpp: Support #elif(expression) with no intervening space.Matt Turner2012-11-287-1/+96
| | | | | | | | | | | | And add test cases to ensure that this works - 110 verifies that glcpp rejects #elif<digits> which glcpp previously accepted. - 111 verifies that glcpp accepts #if followed immediately by (, +, -, !, or ~. - 112 does the same as 111 but for #elif. See 17f9beb6 for #if change. Reviewed-by: Carl Worth <[email protected]>