summaryrefslogtreecommitdiff
path: root/src/glsl/glcpp
AgeCommit message (Collapse)AuthorFilesLines
2014-02-20glcpp: Only warn for macro names containing __Ian Romanick2-5/+21
Section 3.3 (Preprocessor) of the GLSL 1.30 spec (and later) and the GLSL ES spec (all versions) say: "All macro names containing two consecutive underscores ( __ ) are reserved for future use as predefined macro names. All macro names prefixed with "GL_" ("GL" followed by a single underscore) are also reserved." The intention is that names containing __ are reserved for internal use by the implementation, and names prefixed with GL_ are reserved for use by Khronos. Since every extension adds a name prefixed with GL_ (i.e., the name of the extension), that should be an error. Names simply containing __ are dangerous to use, but should be allowed. In similar cases, the C++ preprocessor specification says, "no diagnostic is required." Per the Khronos bug mentioned below, a future version of the GLSL specification will clarify this. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Cc: "9.2 10.0 10.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Tested-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com> Tested-by: Darius Spitznagel <d.spitznagel@goodbytez.de> Cc: Tapani Pälli <lemody@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71870 Bugzilla: Khronos #11702 (cherry picked from commit 0bd78926304e72ef3566e977d0cb5a959d86b809)
2014-01-31glcpp: Reject #version after the version has been resolved.Matt Turner1-0/+6
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74166 Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Carl Worth <cworth@cworth.org>
2014-01-31glcpp: Rename the variable used to enable debugging.Carl Worth1-1/+1
The -p option we now use when calling bison means that this variable will be named glcpp_parser_debug not yydebug. This was not caught when the -p option was added because this variable isn't used in the code as committed. (I prefer the declaration to remain since it allows a developer to easily find this variable name to enable debugging.)
2014-01-31glcpp: Add "make check" test for comment-parsing bugCarl Worth2-0/+5
This is the innocent-looking but killer test case to verify the bug fixed in the preceding commit. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2014-01-31glcpp: Don't enter lexer's NEWLINE_CATCHUP start state for single-line commentsCarl Worth1-2/+0
In commit 6005e9cb28 a new start state of NEWLINE_CATCHUP was added to the lexer. This start state is used whenever the lexer is emitting a NEWLINE token to emit additional NEWLINE tokens for any newline characters that were skipped by an immediately preceding multi-line comment. However, that commit erroneously entered the NEWLINE_CATCHUP state for single-line comments. This is not desired since in the case of a single-line comment, the lexer is not emitting any NEWLINE token. The result is that the lexer will remain in the NEWLINE_CATCHUP state and proceed to fail to emit a NEWLINE token for the subsequent newline character, (since the case to match \n expects only the INITIAL start state). The fix is quite simple, remove the "BEGIN NEWLINE_CATCHUP" code from the single-line comment case, (preserving it only in exactly the cases where the lexer is actually emitting a NEWLINE token). Many thanks to Petri Latvala for reporting this bug and for providing the minimal test case to exercise it. The bug showed up only with a multi-line comment which was followed immediately by a single-line comment (without any intervening newline), such as: /* */ // Kablam! Since 6005e9cb28, and before this commit, that very innocent-looking combination of comments would yield a parse failure in the compiler. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72686 Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2014-01-27glcpp: Resolve implicit GLSL version to 100 if the API is ES.Matt Turner4-5/+16
Fixes a regression since b2d1c579 where ES shaders without a #version declaration would fail to compile if their precision declaration was wrapped in the standard #ifdef GL_ES check. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74066 Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-27glcpp: Check version_resolved in the proper place.Matt Turner3-13/+13
The check was in the wrong place, such that if a shader incorrectly put a preprocessor token before the #version declaration, the version would be resolved twice, leading to a segmentation fault when attempting to redefine the __VERSION__ macro. #extension GL_ARB_sample_shading: require #version 130 void main() {} Also, rename glcpp_parser_resolve_version to glcpp_parser_resolve_implicit_version to avoid confusion. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Carl Worth <cworth@cworth.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-27glcpp: Make sure GL_AMD_shader_trinary_minmax is definedIan Romanick1-3/+2
The define was only available if gl_extensions::AMD_shader_trinary_minmax was set, but no driver set it. Since the extension is advertised by default, remove that field too. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Cc: Maxence Le Doré <maxence.ledore@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
2014-01-23glcpp: Define GL_EXT_shader_integer_mix in both GL and ES.Matt Turner1-3/+5
Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-23glcpp: Remove unused gl_api bits.Matt Turner2-2/+0
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-23glcpp: Set extension defines after resolving the GLSL version.Matt Turner3-143/+172
Instead of defining preprocessor macros in glcpp_parser_create based on the GL API, wait until the shader version has been resolved. Doing this allows us to correctly set (and not set) preprocessor macros for extensions allowed by the API but not the shader, as in the case of ARB_ES3_compatibility. The shader version has been resolved when the preprocessor encounters the first preprocessor token, since the GLSL spec says "The #version directive must occur in a shader before anything else, except for comments and white space." Specifically, if a #version token is found the version is known explicitly, and if any other preprocessor token is found then the GLSL version is implicitly 1.10. Cc: mesa-stable@lists.freedesktop.org Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71630 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-23mesa: Add ARB_arrays_of_arraysTimothy Arceri1-0/+3
Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au> Reviewed-by: Paul Berry <stereotype441@gmail.com>
2014-01-20glsl: Add extension infrastructure for ARB_viewport_arrayIan Romanick1-0/+3
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2014-01-06glsl: Add extension tracking for AMD_shader_trinary_minmaxMaxence Le Doré1-0/+3
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2014-01-02glcpp: error on multiple #else/#elif directivesErik Faye-Lund6-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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Carl Worth <cworth@cworth.org> Cc: 10.0 <mesa-stable@lists.freedesktop.org>
2014-01-02glcpp: Replace multi-line comment with a space (even as part of macro ↵Carl Worth8-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 <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-02glcpp: Add a more descriptive comment for the SKIP state manipulationCarl Worth1-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 <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-11-01mesa: Add infrastructure for GL_ARB_sample_shadingAnuj Phogat1-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 <anuj.phogat@gmail.com> Reviewed-by: Ian Romanick <idr@freedesktop.org> Reviewed-by: Ken Graunke <kenneth@whitecape.org>
2013-10-29glsl: Add built-in functions and constants required for ↵Francisco Jerez1-0/+3
ARB_shader_atomic_counters. v2: Represent atomics as GLSL intrinsics. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-10-05glsl: add plumbing for GL_ARB_texture_query_levelsChris Forbes1-0/+3
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Matt Turner <mattst88@gmail.com>
2013-10-03glsl: add texture gather changesMaxence Le Dore1-0/+3
V2 [Chris Forbes]: - Add new pattern, fixup parameter reading. V3: Rebase onto new builtins machinery Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-09-13mesa: Rename MESA_shader_integer_mix to EXT_shader_integer_mixIan Romanick1-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 <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2013-09-09glsl: Implement MESA_shader_integer_mix extension.Matt Turner1-0/+3
Because why doesn't GLSL allow you to do this already? Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-06-14mesa: Add infrastructure for ARB_shading_language_420pack.Todd Previte1-0/+3
v2 [mattst88] - Split infrastructure into separate patch. - Add preprocessor #define. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-06-13mesa: fix OES_EGL_image_external being partially allowed in the core profileMarek Olšák1-7/+7
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2013-06-10glcpp: Automatically #define GL_core_profile 1 on GLSL 1.50+.Kenneth Graunke1-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 <mattst88@gmail.com> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2013-06-03glcpp: Add test case for recently fixed loop-control underflow bug.Carl Worth2-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 <kenneth@whitecape.org>
2013-06-03glcpp: Fix post-decrement underflow in loop-control variableCarl Worth1-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 <kenneth@whitecape.org>
2013-05-13glsl: add AMD_vertex_shader_layer supportJordan Justen1-0/+3
This GLSL extension requires that AMD_vertex_shader_layer be enabled by the driver. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-05-06mesa: Add infrastructure for ARB_gpu_shader5.Matt Turner1-0/+3
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
2013-03-29glsl: Implement ARB_texture_query_lodDave Airlie1-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 <mattst88@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-03-02glsl: add support for ARB_texture_multisampleChris Forbes1-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 <chrisf@ijw.co.nz> [V2] Reviewed-by: Eric Anholt <eric@anholt.net> [V2] Reviewed-by: Paul Berry <stereotype441@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-01-25glsl: Add infrastructure for ARB_shading_language_packingMatt Turner1-0/+3
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> Reviewed-by: Paul Berry <stereotype441@gmail.com>
2013-01-22glsl/build: Build glcpp via the glsl MakefileMatt Turner2-56/+2
Removing the subdirectory recursion provides a small speed up. Tested-by: Andreas Boll <andreas.boll.dev@gmail.com>
2013-01-20glsl/build: Remove dead LIBRARY_* variablesMatt Turner1-2/+0
Reviewed-by: Andreas Boll <andreas.boll.dev@gmail.com>
2013-01-11glcpp: Add tests for line continuationCarl Worth4-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 <kenneth@whitecape.org>
2013-01-11glcpp: Rewrite line-continuation support to act globally.Carl Worth1-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 <kenneth@whitecape.org>
2013-01-11glcpp: Add --disable-line-continuations argument to standalone glcppCarl Worth1-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 <kenneth@whitecape.org>
2013-01-11glcpp: Allow test-specific arguments for standalone glcpp testsCarl Worth1-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 <kenneth@whitecape.org>
2013-01-11glcpp: Honor the GL context's DisableGLSLLineContinuations optionCarl Worth1-1/+3
And simply don't call into the function that removes line continuations. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-01-11glcpp: Accept pointer to GL context rather than just the API versionCarl Worth3-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 <kenneth@whitecape.org>
2013-01-11glcpp: Reject token pasting operator in GLESMatt Turner1-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 <ian.d.romanick@intel.com> Reviewed-by: Carl Worth <cworth@cworth.org>
2013-01-11glcpp: Make undefined macros illegal in #if and #elif for GLES3Carl Worth1-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 <mattst88@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-01-11glcpp: Add a flag to the parser state to indicate GLES.Carl Worth2-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 <mattst88@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-01-11glcpp: Add back tests/*.out to .gitignoreAndreas Boll1-0/+1
Accidentally removed in ac2793cf3e1e004942c386dfa45f3b5507223f50
2013-01-10Clean up .gitignore filesMatt Turner1-2/+0
2013-01-02glcpp: Typo fix.Adam Jackson1-1/+1
Note: this is a candidate for the 9.0 stable branch. Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-01-02glcpp: Fix visibility CFLAGS in automakeAdam Jackson1-0/+1
Note: this is a candidate for the 9.0 stable branch. Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-12-07program/hash_table.c: rename to program/prog_hash_table.cJordan Justen1-1/+1
Removes a collision of the object file name for main/hash_table and program/hash_table. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-12-06glsl/preprocessor: Handle "#version 300 es" directive.Paul Berry1-4/+17
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Acked-by: Carl Worth <cworth@cworth.org>