summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_lexer.ll
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Parse shared keyword for compute shader variablesJordan Justen2015-11-091-0/+2
| | | | | | | | | | v2: * Move shared parsing under storage qualifiers (tarceri) * Fail to compile if shared is used in non-compute shader (tarceri) * Use separate shared_storage bit for shared variables (tarceri) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Allow use of memory qualifiers with ARB_shader_storage_buffer_object.Iago Toral Quiroga2015-09-251-5/+5
| | | | Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: add support for OES_texture_storage_multisample_2d_arrayTapani Pälli2015-08-271-3/+3
| | | | | | | | | | | v2: use ARB_texture_multisample enable bit Patch adds extension enable bit and enables required keywords and builtin functions for the extension. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Recognise image memory qualifiers in GLSL ES 3.1.Francisco Jerez2015-08-201-5/+5
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Accept supported image types in GLSL ES 3.1.Francisco Jerez2015-08-201-12/+12
| | | | | | | | These are a subset of the image types supported by desktop GL, excluding 1D, 1D array, rectangle, buffer, cube array, 2D MS and 2D MS array texture targets. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: add missing MS sampler builtin types for GLSL ES 3.10Tapani Pälli2015-08-171-3/+4
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add ast/parser support for subroutine parsing storage (v3.2)Dave Airlie2015-07-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | This is the guts of the GLSL parser and AST support for shader subroutines. The code creates a subroutine type in the parser, and uses that there to validate the identifiers. The parser also distinguishes between subroutine types/function prototypes /uniforms and subroutine defintions for functions. Then in the AST conversion it recreates the types, and stores the subroutine definition info or subroutine info into the ir_function along with a side lookup table in the parser state. It also converts subroutine calls into the enhanced ir_call. v2: move to handling method calls in function handling not in field selection. v3: merge Chris's previous parser patches in here, to make it clearer what's changed in one place. v3.1: add more documentation, drop unused include v3.2: drop is_subroutine_def Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Make `subroutine` a reserved keywordChris Forbes2015-07-231-1/+1
| | | | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: add the tessellation extension to the list for the "layout" qualifierMarek Olšák2015-07-231-1/+2
| | | | | | | | | | | | | | | | This is technically not needed, but it makes the compiler return a better error message if tessellation is used with GLSL < 1.50. Instead of: error: syntax error, unexpected NEW_IDENTIFIER, expecting $end It returns: error: #version 150 layout qualifier `triangles' used And the tessellation spec says: OpenGL 3.2 and GLSL 1.50 are required. So it makes perfect sense. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add the patch in/out qualifier (v2)Fabian Bieler2015-07-231-1/+1
| | | | | | v2: Dropped some unrelated reordering in glsl_parser.yy as Ken suggested. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Implement parser support for 'buffer' qualifierKristian Høgsberg2015-07-141-0/+1
| | | | | | | This is used to identify shader storage buffer interface blocks where buffer variables are declared. Reviewed-by: Jordan Justen <[email protected]>
* glsl/es3.1: Allow interger mix built-ins in GLSL ES 3.10Ian Romanick2015-05-041-1/+1
| | | | | | | | v2: Add missing lexer support. Noticed by Tapani. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> [v1]
* glsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+Antia Puentes2015-04-061-0/+17
| | | | | | | | | | | | From GLSL 3.30 and GLSL ES 1.00 on, after processing the line directive (including its new-line), the implementation should behave as if it is compiling at the line number passed as argument. In previous versions, it behaved as if compiling at the passed line number + 1. Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=88815 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: respect the source number set by #line <line> <source>Antia Puentes2015-04-061-2/+1
| | | | | | | | | | | | | | | | | | From GLSL 1.30.10, section 3.3 (Preprocessor): "#line line source-string-number ... After processing this directive (including its new-line), the implementation will behave as if it is compiling at ... source string number source-string-number. Subsequent source strings will be numbered sequentially, until another #line directive overrides that numbering." In the previous implementation the source number was always zero. Subsequent source strings are still not numbered sequentially, because in the glShaderSource implementation we are concatenating the source code strings into one long string. Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=88815 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/lexer: Support double floatsDave Airlie2015-02-191-4/+27
| | | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: GLSL ES identifiers cannot exceed 1024 charactersIago Toral Quiroga2015-02-061-1/+7
| | | | | | | | | | | v2 (Ian Romanick) - Move the check to the lexer before rallocing a copy of the large string. Fixes the following 2 dEQP tests: dEQP-GLES3.functional.shaders.keywords.invalid_identifiers.max_length_vertex dEQP-GLES3.functional.shaders.keywords.invalid_identifiers.max_length_fragment Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use | action in the lexer source to avoid duplicating the float actionNeil Roberts2014-11-271-12/+3
| | | | | | | | Flex and lex have a special action ‘|’ which means to use the same action as the next rule. We can use this to reduce a bit of code duplication in the rules for the various float literal formats. Reviewed-by: Matt Turner <[email protected]>
* glsl: Disallow float literals with the 'f' suffix but no point or exponentNeil Roberts2014-11-271-4/+0
| | | | | | | | According to the GLSL spec float literals like ‘1f’ shouldn't be allowed without adding a decimal point or an exponent. Apparently the AMD driver also disallows this so it seems unlikely that anything would be relying on it. Reviewed-by: Matt Turner <[email protected]>
* util: add _mesa_strtod and _mesa_strtofChia-I Wu2014-10-301-6/+6
| | | | | | | | | Both core mesa and glsl have their own wrappers for strtof_l. Merge and move them to util/. They are compiled with a C++ compiler so that we can make them thread-safe in a following commit. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix memory leak in glsl_lexer.llJuha-Pekka Heikkila2014-09-231-3/+6
| | | | | | | | | | | | | Running fast clear glClear with SNB caused Valgrind to complain about this. v2: line 237 fixed glClear from leaking memory, other strdups are also now changed to ralloc_strdups but I don't know what effect those have. At least no changes in my Piglit quick run. Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add flex options to eliminate the default ruleCarl Worth2014-07-291-10/+1
| | | | | | | | | | | | | | | | | | | | We've had bugs in the past where we have been inadvertently matching the default rule. Just as we did in the pre-processor in the previous commit, we can use: %option warn nodefault in the compiler to instruct flex to not generate the default rule, and further to warn if our set of rules could let any characters go unmatched. With this warning active, flex actually warns that the catch-all rule we recently added to the compiler could never be matched. Since that is all safely determined at compile time now, we can safely drop this run-time compiler error message, (as we do in this commit). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Properly lex extra tokens when handling # directives.Kenneth Graunke2014-07-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this, in the <PP> state, we would hit Flex's default rule, which prints tokens to stdout, rather than returning them as tokens. (Or, after the previous commit, we would hit the new catch-all rule and generate an internal compiler error.) With this commit in place, we generate the desired syntax error. This manifested as a weird bug where shaders with semicolons after extension directives, such as: #extension GL_foo_bar : enable; would print semicolons to the screen, but otherwise compile just fine (even though this is illegal). Fixes Piglit's extension-semicolon.frag test. This also fixes the following Khronos GLES3 conformance tests, (and for real this time): invalid_char_in_name_vertex invalid_char_in_name_fragment Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add an internal-error catch-all ruleCarl Worth2014-07-291-0/+13
| | | | | | | | | | | | | | | | This is to avoid the default, silent flex rule which simply prints the character to stdout. For the following Khronos GLES3 conformance tests: invalid_char_in_name_vertex invalid_char_in_name_fragment With this commit, these tests now report Pass where they previously reported Fail, but Mesa isn't behaving correctly yet. It's now reporting the internal error where what is really desired is a syntax error. Reviewed-by: Jordan Justen <[email protected]>
* glsl: parser changes for GL_ARB_explicit_uniform_locationTapani Pälli2014-06-161-0/+1
| | | | | | | | | | | | Patch adds a preprocessor define for the extension and stores explicit location data for uniforms during AST->HIR conversion. It also sets layout token to be available when having the extension in place. v2: change parser check to require GLSL 330 or enabling GL_ARB_explicit_attrib_location (Ian) v3: fix the check and comment in AST->HIR (Petri) Signed-off-by: Tapani Pälli <[email protected]>
* glsl: add support for `precise` in type_qualifierChris Forbes2014-06-041-0/+3
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Update lexers in glsl and glcpp to hande end position of token.Sir Anthony2014-03-081-1/+2
| | | | Reviewed-by: Carl Worth <[email protected]>
* glsl/sso: Add parser and AST-to-HIR support for separate shader object layoutsIan Romanick2014-02-211-0/+1
| | | | | | | | | | | | GL_ARB_separate_shader_objects adds the ability to specify location layouts for interstage inputs and outputs. In addition, this extension makes 'in' and 'out' generally available for shader inputs and outputs. This mimics the behavior of GL_ARB_explicit_attrib_location. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl/lexer: Add new tokens for ARB_shader_image_load_store.Francisco Jerez2014-02-121-30/+45
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/cs: Handle compute shader local_size_{x,y,z} declaration.Paul Berry2014-02-051-1/+2
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add frontend support for `sample` auxiliary storage qualifierChris Forbes2013-12-071-1/+1
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: Implement parser support for atomic counters.Francisco Jerez2013-11-071-1/+1
| | | | | | | | | | | | | | | | v2: Mark atomic counters as read-only variables. Move offset overlap code to the linker. Use the contains_atomic() convenience method. v3: Use pointer to integer instead of non-const reference. Add comment so we remember to add a spec quotation from the next GLSL release once the issue of atomic counter aggregation within structures is clarified. v4 (idr): Don't use std::map because it's overkill. Add an assertion that ctx->Const.MaxAtomicBufferBindings <= MAX_COMBINED_ATOMIC_BUFFERS. Signed-off-by: Francisco Jerez <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Change the lexer's namespace.Kenneth Graunke2013-07-311-1/+1
| | | | | | | | | | | | Bison 3.0 removes the YYLEX_PARAM macro. In preparation for handling this using %lex-param, the parser needs a wrapper function for the actual Flex lex() function. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67354 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Tested-by: Laurent Carlier <[email protected]> Cc: "9.2" [email protected]
* glsl: Classify "layout" like other identifiers.Kenneth Graunke2013-07-271-1/+1
| | | | | | | | | | | | | When "layout" isn't being lexed as LAYOUT_TOK, we should treat it like an ordinary identifier. This means we need to classify it to determine whether we should return IDENTIFIER, TYPE_IDENTIFIER, or NEW_IDENTIFIER. Fixes the WebGL conformance test "shader-with-non-reserved-words." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64087 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: [email protected]
* glsl: Be consistent about '\n', '.', and capitalization in errors/warnings.Paul Berry2013-07-271-5/+5
| | | | | | | | | | | | The majority of calls to _mesa_glsl_error(), _mesa_glsl_warning(), and _mesa_glsl_parse_state::check_version() use a message that begins with a lower case letter and ends without a period. This patch makes all messages follow that convention. Also, error/warning messages shouldn't end in '\n', since _mesa_glsl_msg() automatically adds '\n' at the end of the message. Reviewed-by: Matt Turner <[email protected]>
* glsl: disable ARB_texture_cube_map_array_enable keywords for glsl esTapani Pälli2013-07-261-24/+5
| | | | | | | | | | | | Patch fixes a crash with Webgl 'shader-with-non-reserved-words' conformance test by ignoring desktop extension keywords on GLSL ES. v2: fix reserved and allowed desktop glsl versions (Chris) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64087 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Have the lexer return LAYOUT_TOK if 420pack is enabled.Kenneth Graunke2013-07-181-1/+2
| | | | | | | GL_ARB_shading_language_420pack also provides layout qualifiers. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Mark "row_major" as not a reserved word in GLSL ES 3.0.Matt Turner2013-07-111-2/+2
| | | | | | | | | | We mark ARB_uniform_buffer_object as enabled under ES 3 since it contains that functionality, which tricked the compiler into tokenizing "row_major". Acked-by: Anuj Phogat <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add support for ARB_texture_multisampleChris Forbes2013-03-021-6/+9
| | | | | | | | | | | | | | | | | | 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: use glsl_strtof() instead of glsl_strtod()Brian Paul2013-01-251-5/+5
| | | | | | Since the result of those calls is always assigned to a float. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Allow layout qualifiers in GLSL 3.00 ESIan Romanick2012-12-061-1/+1
| | | | | | | | | | Note that while 'packed' is a reserved word in GLSL ES, row_major is not. This means that we have to use the string-based matching for that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Enable GLSL ES 3.00 features inherited from desktop GLSL.Paul Berry2012-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | 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-061-78/+111
| | | | | | | | | | | | | | | | | | | | | 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::is_version() function.Paul Berry2012-12-061-2/+2
| | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: add ARB_texture_cube_map_array support (v2)Dave Airlie2012-11-091-2/+27
| | | | | | | | | | | | 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: Add parsing for GLSL uniform blocks.Eric Anholt2012-07-091-2/+3
| | | | | | | | This doesn't do anything with the uniform block declarations yet, so usage of those uniforms finds them to be undeclared. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Mark [iu]sampler{Buffer,2DRect}as reserved in GLSL 1.40.Eric Anholt2012-04-161-0/+6
| | | | | | | | | The non-integer versions were already reserved in 1.30, but apparently these were forgotten. Fixes piglit glsl-1.40/compiler/reserved/ Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: rename VERSION to VERSION_TOK for automakeMatt Turner2012-01-041-1/+1
| | | | Signed-off-by: Matt Turner <[email protected]>
* glsl: finish up ARB_conservative_depth (v2)Marek Olšák2011-11-221-0/+1
| | | | | | | v2: updated an error message Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add support for GL_OES_EGL_image_externalChia-I Wu2011-11-031-0/+7
| | | | | | | | | | This extension introduces a new sampler type: samplerExternalOES. texture2D (and texture2DProj) can be used to do a texture look up in an external texture. Reviewed-by: Brian Paul <[email protected]> Acked-by: Jakob Bornecrantz <[email protected]> Reviewed-by: Ian Romanick <[email protected]>