summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Record in gl_shader whether the shader uses GLSL ES.Paul Berry2012-12-061-0/+1
| | | | | | | | | | | | | | | | | | Previously we recorded just the GLSL version, with the knowledge that 100 means GLSL 1.00 ES. With the advent of GLSL 3.00 ES, this is going to get more complex, and eventually will probably become ambiguous (GLSL 4.00 already exists, and GLSL 4.00 ES is likely to be created some day). To reduce confusion, this patch simply records whether the shader is GLSL ES as an explicit boolean. [v2, idr]: s/IsEs(Shader|Prog)/IsES/ Suggested by Ken and Eric. Reviewed-by: Ian Romanick <[email protected]> [v1] Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/parser: Handle "#version 300 es" directive.Paul Berry2012-12-063-28/+86
| | | | | | | | | | | | | | | Note that GLSL 1.00 is selected using "#version 100", so "#version 100 es" is prohibited. v2: Check for GLES3 before allowing '#version 300 es' v3: Make sure a correct language_version is set in _mesa_glsl_parse_state::process_version_directive. Signed-off-by: Paul Berry <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/parser: Extract version directive processing into a function.Paul Berry2012-12-063-42/+55
| | | | | | | | | | | | | | 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. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[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]>
* glsl: Enable GLSL ES 3.00 features inherited from desktop GLSL.Paul Berry2012-12-065-17/+47
| | | | | | | | | | | | | | | | | | | | This patch turns on the following features for GLSL ES 3.00: - Array constructors, whole array assignment, and array comparisons. - Second and third operands of ?: may be arrays. - Use of "in" and "out" qualifiers on globals. - Bitwise and modulus operators. - Integral vertex shader inputs. - Range-checking of literal integers. - array.length method. - Function calls may be constant expressions. - Integral varyings must be qualified with "flat". - Interpolation and centroid qualifiers may not be applied to vertex shader inputs. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: parse GLSL ES 3.00 keywords correctly.Paul Berry2012-12-062-78/+114
| | | | | | | | | | | | | | | | | | | | | GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint, uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout, switch, default, and case. Additionally, it reserves a large number of keywords, some of which were already reserved in versions of desktop GL that Mesa supports, some of which are new to Mesa. A few of the reserved keywords in GLSL ES 3.00 are keywords that are supported in all other versions of GLSL: attribute, varying, sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow. This patch updates the lexer to handle all of the new keywords correctly when the language being parsed is GLSL 3.00 ES. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Rework lexer keyword handling in preparation for GLSL 3.00 ES.Paul Berry2012-12-061-132/+136
| | | | | | | | | | | | | | | | | | | | | | | | This patch expands the lexer KEYWORD macro to take two additional arguments: the GLSL ES versions in which the given keyword was first reserved, and supported, respectively. This will allow us to trivially add support for GLSL 3.00 ES keywords, even though the set of GLSL 3.00 ES keywords is neither a subset or a superset of the keywords corresponding to any desktop GLSL version. The new KEYWORD macro makes use of the _mesa_glsl_parse_state::is_version() function, so it accepts 0 as meaning "unsupported" (rather than 999, which we used previously). Note that a few keywords ("packed" and "row_major") are supported *either* when GLSL 1.40 is in use or when ARB_uniform_buffer_obj support is enabled. Previously, we handled these by cleverly taking advantage of the fact that the KEYWORD macro didn't parenthesize its arguments in the usual way. Now they are handled more straightforwardly, with a new macro, KEYWORD_WITH_ALT. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make use of new _mesa_glsl_parse_state::check_version() function.Paul Berry2012-12-065-74/+50
| | | | | | | | | | | | | | | | | | Previous to this patch, we were not very consistent about the errors we generate when a shader tried to use a feature that is prohibited in the current GLSL version. Some error messages failed to mention the GLSL version currently in use (or did so inaccurately), and some error messages failed to mention the first GLSL version in which the given feature is allowed. This patch reworks all of the error checks to use the check_version() function, which produces error messages in a standard form (approximately "$FEATURE forbidden in $CURRENT_GLSL_VERSION ($REQUIRED_GLSL_VERSION required)."). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make use of new _mesa_glsl_parse_state::is_version() function.Paul Berry2012-12-065-26/+33
| | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Add GLSL version query functions.Paul Berry2012-12-062-10/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | With the advent of GLSL 3.00 ES, the version checks we perform in the GLSL compiler (to determine which language features are present) will become more complicated. To reduce the complexity, this patch adds functions check_version() and is_version() to _mesa_glsl_parse_state. These functions take two version numbers: a desktop GLSL version and a GLSL ES version, and return a boolean indicating whether the GLSL version being compiled is at least the required version. So, for example, is_version(130, 300) returns true if the GLSL version being compiled is at least desktop GLSL 1.30 or GLSL 3.00. The check_version() function additionally produces an error message if the version check fails, informing the user of which GLSL version(s) support the given feature. [v2, idr]: Add PRINTFLIKE annotation to the new method. The numbering of th parameters is correct because GCC is silly. [v3, idr]: Fix copy-and-paste error in the comment before _mesa_glsl_parse_state::is_version. Noticed by Ken. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Compute version_string on the fly.Paul Berry2012-12-063-12/+18
| | | | | | | | Fixes a bug where version_string would be left uninitialized if no GLSL "#version" directive was used. Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make a function to express a GLSL version ir human-readable form.Paul Berry2012-12-063-4/+15
| | | | | | | | | | | This will be useful in generating more helpful error messages, especially with the addition of GLSL 3.00 ES support. [v2, idr]: Rename ctx parameter to mem_ctx Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Simplify symbol table version checking.Paul Berry2012-12-065-7/+9
| | | | | | | | | | | Previously, we stored the GLSL language version in the glsl_symbol_table struct. But this was unnecessary--all glsl_symbol_table needs to know is whether functions and variables have separate namespaces (they do in GLSL 1.10 only). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* mesa: Add ARB_ES3_compatibility flag.Paul Berry2012-12-062-0/+2
| | | | | | | | | | | | | Adding this now makes it easier to develop and test GLES3 features, since we can do initial development and testing using desktop GL. Later GLSL compiler patches check for either ctx->Extensions.ARB_ES3_compatibility or _mesa_is_gles3 to allow certain features (i.e., "#version 300 es"). [v2, idr]: Just edits to the commit message. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: add new variable declaration in function body in lower_output_readVincent Lejeune2012-12-051-0/+1
| | | | Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
* glsl: fix uninitialised variable from constructorDave Airlie2012-12-011-0/+1
| | | | | | | | | Coverity pointed out this uninitialised class member. Note: This is a candidate for stable branches. Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: initialise killed_all field.Dave Airlie2012-12-011-0/+1
| | | | | | | | | coverity pointed out this field was being used uninitialised. Note: This is a candidate for stable branches. Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: fix cut-n-paste error in error handling. (v2)Dave Airlie2012-12-011-2/+2
| | | | | | | | | | | | Reported by coverity scan. v2: fix second case Note: This is a candidate for stable branches. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[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-294-4/+4
| | | | | | | | | | 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]>
* glcpp: Reject #version and #line not followed by whitespaceMatt Turner2012-11-285-2/+8
| | | | | Fixes part of es3conform's preprocess16_frag test. Reviewed-by: Carl Worth <[email protected]>
* glsl: Support unsigned integer constants in layout qualifiers.Kenneth Graunke2012-11-261-1/+6
| | | | | | | Fixes es3conform's explicit_attrib_location_integer_constants. Reviewed-by: Eric Anholt <[email protected]> Reviewed-and-tested-by: Matt Turner <[email protected]>
* mesa: Fix linker-assigned varying component counting since 8fb1e4a462Eric Anholt2012-11-171-2/+1
| | | | | | | | | | | | | | | The goal of that change was to skip counting things that aren't actually outputs from the VS to the FS. However, explicit_location isn't set in the case of linker-assigned locations (the common case), so basically varying component counting got disabled. At this stage of the linker, we've already ensured that var->location is set, so we can just look at it without worrying. Fixes i965 assertion failure with the new piglit glsl-max-varyings --exceed-limits. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51545 Reviewed-by: Brian Paul <[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]>
* automake: Remove empty file variable.Brian Paul2012-11-121-2/+1
| | | | | | | | Fixes SCons build regression introduced with commit a665cf1226b80ec52a0c1a4a38378df4389e8ebf. Signed-off-by: Vinson Lee <[email protected]> Tested-by: Vinson Lee <[email protected]>
* automake: Merge *_CXX_FILES variables in the glsl build.Eric Anholt2012-11-124-10/+6
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* automake: Fix a comment typo.Eric Anholt2012-11-121-1/+1
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: store read vector in a temp in vec_index_to_condVincent Lejeune2012-11-111-4/+12
| | | | | | | | | | | | | | | | | | | | | Vector indexing on matrixes generates several copy of the constant matrix, for instance vec=mat4[i][j] generates : vec=mat4[i].x; vec=(j==1)?mat4[i].y; vec=(j==2)?mat4[i].z; vec=(j==3)?mat4[i].w; In the case of constant matrixes, the mat4[i] expression generates copy of the 16 elements of the matrix 4 times ; indirect addressing also prevents some conservative CSE algorithms (like the one in LLVM) from factoring the mat4[i] expression. This patch will make the vec_index_to_cond pass generates : temp = mat4[i]; vec=temp.x; vec=(j==1)?temp.y; vec=(j==2)?temp.z; vec=(j==3)?temp.w; Reviewed-by: Kenneth Graunke <[email protected]>
* Fix use of glsl_parser.{cc,h} where source dir != build dir.Darren Salt2012-11-091-1/+2
| | | | | | | | Fixes a regression caused by commit 9948a3365. https://bugs.freedesktop.org/show_bug.cgi?id=56787 https://bugs.freedesktop.org/show_bug.cgi?id=56685 Reviewed-by: Matt Turner <[email protected]>
* glcpp: wire up glcpp-test to make checkMatt Turner2012-11-092-4/+14
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp/tests: Add tests for multiline #elifMatt Turner2012-11-092-0/+15
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp/tests: Add test for multiline #ifMatt Turner2012-11-092-0/+13
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp/tests: Add test for multiline #lineMatt Turner2012-11-092-0/+11
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp/tests: Add test to check #line followed by codeMatt Turner2012-11-092-0/+5
| | | | | | | 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 Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: don't push #line directives into next lineFabian Bieler2012-11-092-9/+9
| | | | | | | | | | | | | | 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-095-4/+15
| | | | | | | | | | | | | | | | | | | | | | 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-0912-7/+114
| | | | | | | | | | | | 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]>
* glsl: fix signed/unsigned comparision warnings on MSVCBrian Paul2012-11-063-7/+7
| | | | Reviewed-by: Jose Fonseca <[email protected]>
* glsl: remove incorrect 'struct' keywordBrian Paul2012-11-061-1/+1
| | | | | | ir_variable is a class, not a struct. Fixes an MSVC warning. Reviewed-by: Jose Fonseca <[email protected]>