aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glcpp
Commit message (Collapse)AuthorAgeFilesLines
* glcpp: Handle '#version 0' and other invalid valuesIan Romanick2016-11-102-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The #version directive can only handle decimal constants. Enforce that the value is a decimal constant. Section 3.3 (Preprocessor) of the GLSL 4.50 spec says: The language version a shader is written to is specified by #version number profile opt where number must be a version of the language, following the same convention as __VERSION__ above. The same section also says: __VERSION__ will substitute a decimal integer reflecting the version number of the OpenGL shading language. Use a separate flag to track whether or not the #version line has been encountered. Any possible sentinel (0 is currently used) could be specified in a #version directive. This would lead to trying to (internally) redefine __VERSION__. Since there is no parser location for this addition, NULL is passed. This eventually results in a NULL dereference and a segfault. Attempts to use -1 as the sentinel would also fail if '#version 4294967295' or '#version 18446744073709551615' were used. We should have piglit tests for both of these. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420 Reviewed-by: Nicolai Hähnle <[email protected]> Cc: [email protected] Cc: Juan A. Suarez Romero <[email protected]> Cc: Karol Herbst <[email protected]>
* glcpp: use the linear allocator for most objectsMarek Olšák2016-10-313-118/+91
| | | | | | | v2: cosmetic changes Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* glsl/glcpp: initialize all fields of glcpp_parser_t on creationTapani Pälli2016-10-311-0/+3
| | | | | | | | this fixes some of the regressions with "ralloc: remove memset from ralloc_size" Signed-off-by: Tapani Pälli <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: Convert glcpp-parse to the util hash tableThomas Helland2016-09-122-21/+35
| | | | | | | | | And change the include in glcpp.h accordingly. V2: Whitespace fix Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glcpp: Update tests for new #undef of built-in macro rules.Kenneth Graunke2016-08-154-1/+11
| | | | | | | | | | | | | | Ian recently changed the preprocessor to allow this in most GLSL versions, but not GLSL ES 3.00+. This patch converts the existing test that expects a failure to a #version 300 es shader, and adds a #version 110 shader to make sure that it's allowed. Fixes 'make check'. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97307 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Vinson Lee <[email protected]>
* glcpp: Only disallow #undef of pre-defined macros on GLSL ES >= 3.00 shadersIan Romanick2016-08-101-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Section 3.4 (Preprocessor) of the GLSL ES 3.00 spec says: It is an error to undefine or to redefine a built-in (pre-defined) macro name. The GLSL ES 1.00 spec does not contain this text. Section 3.3 (Preprocessor) of the GLSL 1.30 spec says: #define and #undef functionality are defined as is standard for C++ preprocessors for macro definitions both with and without macro parameters. At least as far as I can tell GCC allow '#undef __FILE__'. Furthermore, there are desktop OpenGL conformance tests that expect '#undef __VERSION__' and '#undef GL_core_profile' to work. Fixes: GL45-CTS.shaders.preprocessor.definitions.undefine_version_vertex GL45-CTS.shaders.preprocessor.definitions.undefine_version_fragment GL45-CTS.shaders.preprocessor.definitions.undefine_core_profile_vertex GL45-CTS.shaders.preprocessor.definitions.undefine_core_profile_fragment Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* glcpp: Track the actual version instead of just the version_resolved flagIan Romanick2016-08-102-6/+6
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* glsl: reuse main extension table to appropriately restrict extensionsIlia Mirkin2016-07-234-203/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were only restricting based on ES/non-ES-ness and whether the overall enable bit had been flipped on. However we have been adding more fine-grained restrictions, such as based on compat profiles, as well as specific ES versions. Most of the time this doesn't matter, but it can create awkward situations and duplication of logic. Here we separate the main extension table into a separate object file, linked to the glsl compiler, which makes use of it with a custom function which takes the ES-ness of the shader into account (thus allowing desktop shaders to properly use ES extensions that would otherwise have been disallowed.) We can also now use this logic to generate #define's for all supported extensions automatically, removing the duplicate (and often inaccurate) list in glcpp. The effect of this change should be nil in most cases. However in some situations, extensions like GL_ARB_gpu_shader5 which were formerly available in compat contexts on the GLSL side of things will now become inaccessible. This regresses two ES CTS tests: ES3-CTS.shaders.shader_integer_mix.define ES31-CTS.shader_integer_mix.define however that is due to them using #version 100 instead of 300 es. As the extension is only defined for ES3, I believe this is the correct behavior. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> (v2) v2 -> v3: integrate glcpp defines into the same mechanism
* MESA_shader_integer_functions: Boiler plate extension trackingIan Romanick2016-07-191-0/+3
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa: hook up core bits of GL_ARB_shader_group_voteIlia Mirkin2016-06-061-0/+3
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* mesa: Add extension tracking for GL_OES_shader_io_blocksIan Romanick2016-05-261-0/+5
| | | | | | | | | v2: Also support GL_EXT_shader_io_blocks. It's pretty much identical to the OES extension. Suggested by Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: add GL_EXT_clip_cull_distance define, add helpersIlia Mirkin2016-05-251-0/+2
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Tobias Klausmann <[email protected]>
* glsl: Add arb_cull_distance support (v3)Tobias Klausmann2016-05-141-0/+3
| | | | | | | | | v2: make too large array a compile error v3: squash mesa/prog patch to avoid static compiler errors in bisect Signed-off-by: Tobias Klausmann <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: add ARB_ES3_1_compatibility supportIlia Mirkin2016-04-031-0/+3
| | | | | | | | Oddly a bunch of the features it adds are actually from ESSL 3.20. But the spec is quite clear, oh well. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: remove tabs and fix some other style issues in glcpp-parse.yTimothy Arceri2016-04-021-1424/+1352
| | | | | | Note there are still tabs left in the parser rules. Acked-by: Dave Airlie <[email protected]>
* mesa: add GL_OES_shader_multisample_interpolation supportIlia Mirkin2016-03-301-1/+3
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add GL_OES_sample_variables supportIlia Mirkin2016-03-301-0/+2
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add OES_texture_buffer and EXT_texture_buffer supportIlia Mirkin2016-03-281-0/+4
| | | | | | | | | Expose the samplerBuffer/imageBuffer types, and allow the various functions to operate on them. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: add GL_ARB_shader_atomic_counter_ops supportIlia Mirkin2016-03-101-0/+3
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glcpp: Fix locations when encounting "#<NEWLINE>".Kenneth Graunke2016-03-102-1/+4
| | | | | | | | | | | | | | | We were failing to reset our location tracking when encountering a NEWLINE in the <HASH> state. Rip the code from the <*>{NEWLINE} rule, which handles this properly. Also, update 146-version-first-hash.c to have proper expectations. When I introduced the test, I didn't verify that the line/column numbers were correct, and it turns out they varied based on the type of newline ending. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94447 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glcpp: Remove empty mid-rule action which changes test behavior.Kenneth Graunke2016-03-072-2/+2
| | | | | | | | | | Apparently this causes a slight difference in the parser's token expectations, leading to a different error message. It seems harmless, but I wanted to be cautious and separate it out. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Clean up most empty mid-rule actions left by previous commit.Kenneth Graunke2016-03-071-18/+18
| | | | | | | | I didn't want to pollute the previous patch with all the $4 -> $3 changes. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Delete unnecessary implicit version resolves.Kenneth Graunke2016-03-071-18/+6
| | | | | | | | We now have a bigger hammer. The HASH_TOKEN NEWLINE rule still needs to exist to ensure the 146-version-hash-first.c test still passes. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Implicitly resolve version after the first non-space/hash token.Kenneth Graunke2016-03-078-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We resolved the implicit version directive when processing control lines, such as #ifdef, to ensure any built-in macros exist. However, we failed to resolve it when handling ordinary text. For example, int x = __VERSION__; should resolve __VERSION__ to 110, but since we never resolved the implicit version, none of the built-in macros exist, so it was left as is. This also meant we allowed the following shader to slop through: 123 #version 120 Nothing would cause the implicit version to take effect, so when we saw the #version directive, we thought everything was peachy. This patch makes the lexer's per-token action resolve the implicit version on the first non-space/newline/hash token that isn't part of a #version directive, fulfilling the GLSL language spec: "The #version directive must occur in a shader before anything else, except for comments and white space." Because we emit #version as HASH_TOKEN then VERSION_TOKEN, we have to allow HASH_TOKEN to slop through as well, so we don't resolve the implicit version as soon as we see the # character. However, this is fine, because the parser's HASH_TOKEN NEWLINE rule does resolve the version, disallowing cases like: # #version 120 This patch also adds the above shaders as new glcpp tests. Fixes dEQP-GLES2.functional.shaders.preprocessor.predefined_macros. {gl_es_1_vertex,gl_es_1_fragment}. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: add GL_OES_gpu_shader5 and GL_EXT_gpu_shader5 supportIlia Mirkin2016-02-271-0/+4
| | | | | | | | | | | The two extensions are identical, and are largely taking bits of already existing desktop functionality. We continue to do a poor job of supporting the 'precise' keyword, just like we do on desktop. This passes the relevant dEQP tests that I could find. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Add usual extension boilerplate for OES_shader_image_atomic.Francisco Jerez2016-02-221-0/+3
| | | | | | v2: No need for extension enable bits (Ilia). Reviewed-by: Ilia Mirkin <[email protected]>
* glcpp: Disallow "defined" as a macro name.Kenneth Graunke2016-02-181-0/+3
| | | | | | | | | | Both GCC and Clang disallow this, and glslang has recently started disallowing it as well. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94188 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add GL_OES_geometry_point_size and conditionalize gl_PointSizeIlia Mirkin2016-01-261-0/+7
| | | | | | | | | | | For now this will be enabled in tandem with GL_OES_geometry_shader. Should a driver come along that wants to separate them out, another enable can be added. Also adds the missed GL_OES_geometry_shader define in glcpp. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]>
* glsl: move to compiler/Emil Velikov2016-01-26298-0/+6284
Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>