summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/pp.c
Commit message (Collapse)AuthorAgeFilesLines
* glcpp: Resolve implicit GLSL version to 100 if the API is ES.Matt Turner2014-01-271-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 <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Check version_resolved in the proper place.Matt Turner2014-01-271-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 <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Set extension defines after resolving the GLSL version.Matt Turner2014-01-231-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: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71630 Reviewed-by: Ian Romanick <[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]>
* 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: 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-111-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 <[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]>
* mesa/glsl: rename preprocess to glcpp_preprocessDave Airlie2012-09-151-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 <[email protected]> Signed-off-by: Dave Airlie <[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]>
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-16/+14
|
* glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.Kenneth Graunke2010-09-071-2/+2
| | | | Also define it if #version 100 is encountered.
* glsl2: remove 'extern' keyword in .c fileBrian Paul2010-08-271-1/+1
|
* glsl/mesa: fixes for MSVCAras Pranckevicius2010-08-251-0/+1
| | | | Signed-off-by: Brian Paul <[email protected]>
* glsl2: Include string.h in preprocessorJakob Bornecrantz2010-08-131-0/+1
|
* glcpp: Fix "unterminated if" diagnostic.Carl Worth2010-08-111-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.
* glsl2: move declarations before codeBrian Paul2010-08-111-2/+4
|
* glcpp: Don't look for backslashes before the beginning of the string.Kenneth Graunke2010-07-301-3/+7
| | | | Fixes a valgrind error.
* glsl2: Conditionally define preprocessor tokens for optional extensionsIan Romanick2010-07-011-2/+3
| | | | | The only optional extension currently supported by the compiler is GL_EXT_texture_array.
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+155