summaryrefslogtreecommitdiff
path: root/src/glsl/glcpp/pp.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-27glcpp: Resolve implicit GLSL version to 100 if the API is ES.Matt Turner1-1/+1
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 Turner1-1/+1
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-23glcpp: Set extension defines after resolving the GLSL version.Matt Turner1-1/+3
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>
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-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: 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 Worth1-2/+2
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>
2012-11-30Revert "glcpp: Rewrite line-continuation support to act globally."Carl Worth1-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.
2012-11-30glcpp: Rewrite line-continuation support to act globally.Carl Worth1-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 <kenneth@whitecape.org>
2012-09-15mesa/glsl: rename preprocess to glcpp_preprocessDave Airlie1-1/+1
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>
2012-06-26glsl: Consistently use length-based ralloc string functions for info_log.Carl Worth1-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 <cworth@cworth.org> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-01-31Convert everything from the talloc API to the ralloc API.Kenneth Graunke1-16/+14
2010-09-07glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.Kenneth Graunke1-2/+2
Also define it if #version 100 is encountered.
2010-08-27glsl2: remove 'extern' keyword in .c fileBrian Paul1-1/+1
2010-08-25glsl/mesa: fixes for MSVCAras Pranckevicius1-0/+1
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-08-13glsl2: Include string.h in preprocessorJakob Bornecrantz1-0/+1
2010-08-11glcpp: Fix "unterminated if" diagnostic.Carl Worth1-0/+3
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.
2010-08-11glsl2: move declarations before codeBrian Paul1-2/+4
2010-07-30glcpp: Don't look for backslashes before the beginning of the string.Kenneth Graunke1-3/+7
Fixes a valgrind error.
2010-07-01glsl2: Conditionally define preprocessor tokens for optional extensionsIan Romanick1-2/+3
The only optional extension currently supported by the compiler is GL_EXT_texture_array.
2010-06-24glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt1-0/+155