summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser.yy
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Parse the allowed image format qualifiers in GLSL ES 3.1.Francisco Jerez2015-08-201-41/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes the minimum required desktop/ES GLSL version in the format qualifier table in anticipation of new GLSL versions extending the set of supported image formats. According to section 4.4.7 of the GLSL ES 3.1 spec: "The format layout qualifier identifiers for image variable declarations are: [...] rgba32f rgba16f r32f rgba8 rgba8_snorm [...] rgba32i rgba16i rgba8i r32i [...] rgba32ui rgba16ui rgba8ui r32ui" Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Fix up GL_ARB_compute_shader for GLSL ES 3.1Marta Lofstedt2015-08-191-3/+2
| | | | | | | | | | GL_ARB_compute_shader is limited for GLSL version 430. This enables for GLSL ES version 310. V2: Updated error string to also include GLSL 3.10 Signed-off-by: Marta Lofstedt <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: enable conservative depth, ssbo based on GLSL versionIlia Mirkin2015-07-271-2/+3
| | | | | | | | Add in missed version checks in the GLSL parser Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: recognize ARB_shading_language_420pack to be enabled with 4.20+Ilia Mirkin2015-07-241-9/+9
| | | | | | | | | The 420pack extension enables various GLSL rules that need to be applied to any GLSL 4.20+ shader even if the extension is not explicitly enabled. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: add ast/parser support for subroutine parsing storage (v3.2)Dave Airlie2015-07-231-61/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: add the patch in/out qualifier (v2)Fabian Bieler2015-07-231-1/+5
| | | | | | v2: Dropped some unrelated reordering in glsl_parser.yy as Ken suggested. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add tessellation shader parsing support (v2)Fabian Bieler2015-07-231-6/+116
| | | | | | v2: Fixed things that Ken suggested. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: enable binding layout qualifier usage for shader storage buffer objectsSamuel Iglesias Gonsalvez2015-07-141-1/+2
| | | | | | | | | | | | See GLSL 4.30 spec, section 4.4.5 "Uniform and Shader Storage Block Layout Qualifiers". v2: - Add whitespace in an error message. Delete period '.' at the end of that error message (Jordan). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Implement parser support for 'buffer' qualifierKristian Høgsberg2015-07-141-4/+26
| | | | | | | This is used to identify shader storage buffer interface blocks where buffer variables are declared. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add glsl_parser_state::has_atomic_counters helperIan Romanick2015-05-041-2/+2
| | | | | | | v2: Change GL version from 400 to 420. Noticed by Tapani and Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Error out on invalid uses of the early_fragment_tests layout qualifier.Francisco Jerez2015-05-041-0/+15
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Split off memory qualifiers from storage qualifiers.Francisco Jerez2015-05-041-1/+16
| | | | | | | | Image memory qualifiers (coherent, volatile, restrict, readonly and writeonly) follow slightly different rules from storage qualifiers, e.g. the uniqueness rule doesn't apply. Make them a separate non-terminal. Reviewed-by: Matt Turner <[email protected]>
* glsl: Disable MSVC switch warning on a per-file basis.Jose Fonseca2015-03-221-0/+4
| | | | | | | | | | | | | This addresses ...\glsl_parser.cpp(...) : warning C4065: switch statement contains 'default' but no 'case' labels This is on code generated by bison, which we have little control. It seems useful to have this warning otherwise enabled. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: replace Elements() with ARRAY_SIZE()Brian Paul2015-03-021-2/+2
| | | | Acked-by: Ilia Mirkin <[email protected]>
* glsl: don't allow invariant qualifiers for interface blocksSamuel Iglesias Gonsalvez2015-02-201-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL 1.50 and GLSL 4.40 specs, they both say the same in "Interface Blocks" section: "If optional qualifiers are used, they can include interpolation qualifiers, auxiliary storage qualifiers, and storage qualifiers and they must declare an input, output, or uniform member consistent with the interface qualifier of the block" From GLSL ES 3.0, chapter 4.3.7 "Interface Blocks", page 38: "GLSL ES 3.0 does not support interface blocks for shader inputs or outputs." and from GLSL ES 3.0, chapter 4.6.1 "The invariant qualifier", page 52. "Only variables output from a shader can be candidates for invariance." This patch fixes the following dEQP tests: dEQP-GLES3.functional.shaders.declarations.invalid_declarations.invariant_uniform_block_2_vertex dEQP-GLES3.functional.shaders.declarations.invalid_declarations.invariant_uniform_block_2_fragment No piglit regressions. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> v2: - Enable this check for GLSL. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/parser: Support double floatsDave Airlie2015-02-191-4/+29
| | | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: invariant qualifier is not valid for shader inputs in GLSL ES 3.00Samuel Iglesias Gonsalvez2014-12-091-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL ES 3.00 spec, chapter 4.6.1 "The Invariant Qualifier", Only variables output from a shader can be candidates for invariance. This includes user-defined output variables and the built-in output variables. As only outputs can be declared as invariant, an invariant output from one shader stage will still match an input of a subsequent stage without the input being declared as invariant. This patch fixes the following dEQP tests: dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_interp_storage_precision dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_interp_storage dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_storage_precision dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_storage dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_interp_storage_precision_invariant_input dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_interp_storage_invariant_input dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_storage_precision_invariant_input dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_storage_invariant_input No piglit regressions observed. v2: - Add spec content in the code Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: throw error when using invariant(all) in a fragment shaderTapani Pälli2014-12-031-1/+12
| | | | | | | | Note that some of the GLSL specifications explicitly state this as compile error, some simply state that 'it is an error'. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Add strings.h on non-MSC platformsAlexander von Gluck IV2014-08-271-0/+3
| | | | | | | | | | | | * IEEE Std 1003.1-2001 placed strcasecmp() in strings.h. * ISO C99 doesn't mention strcase* in string.h * On all platforms I could find, strcasecmp is in strings.h and string.h as a compatibility layer for software written pre-2001 POSIX * Technically strcasecmp should be only in strings.h and the man pages back this up. * Tested build on CentOS and Haiku Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove bogus "OUPTUT" tokenChris Forbes2014-08-261-1/+1
| | | | | | | | This is never used. There is another token "OUTPUT" which the lexer can generate, though. This has been around since the dawn of time; is most likely a typo. Signed-off-by: Chris Forbes <[email protected]>
* glsl: add a mechanism to allow #extension directives in the middle of shadersMarek Olšák2014-07-181-0/+8
| | | | | | | | | | | This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work with sample shading. Also, if this is disabled, the error message at least makes sense now. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add parsing support for multi-stream output in geometry shaders.Samuel Iglesias Gonsalvez2014-06-301-0/+53
| | | | | | | | This implements parsing requirements for multi-stream support in geometry shaders as defined in ARB_gpu_shader5. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Relax combinations of layout qualifiers with other qualifiers.Chris Forbes2014-06-261-28/+8
| | | | | | | | | | | | | | | | | | | Previously we disallowed any combination of layout with interpolation, invariant, or precise qualifiers. There is very little spec guidance on exactly which combinations should be allowed, but with ARB_sso it's useful to allow these qualifiers with rendezvous-by-location. Since it's unclear exactly where the layout qualifier should appear when combined with other qualifiers, we will allow it anywhere before the auxiliary storage qualifier. This allows enough flexibility for all examples I've seen, while keeping the auxiliary-storage-qualifier / storage-qualifier pair together (as they are a single qualifier in the spec prior to ARB_shading_language_420pack) Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix typo in comment.Chris Forbes2014-06-121-1/+1
| | | | Signed-off-by: Chris Forbes <[email protected]>
* glsl: Allow `precise` as a parameter qualifierChris Forbes2014-06-041-2/+10
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Add support for `precise` redeclarationsChris Forbes2014-06-041-0/+12
| | | | | | | | This works like glsl-1.20+'s invariant redeclarations, but with fewer restrictions, since `precise` is allowed on pretty much anything. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: add support for `precise` in type_qualifierChris Forbes2014-06-041-8/+31
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: remove outdated comment, move sample to correct blockChris Forbes2014-06-041-3/+3
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: fix bogus layout qualifier warningsTapani Pälli2014-05-061-4/+7
| | | | | | | | | | Print out GL_ARB_explicit_attrib_location warnings only when parsing attribute that uses "location" qualifier. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77245 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Cc: "10.1 10.2" <[email protected]>
* glsl: make static constant variables "static const"Chia-I Wu2014-05-021-2/+2
| | | | | | | | | This allows them to be moved to .rodata, and allow us to be sure that they will not be modified. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: remove {add,get}_type_ast from glsl_symbol_tableChia-I Wu2014-03-281-1/+0
| | | | | | | They are not needed since 0da1a2cc369052643ccaea75a1722cc37652d82a. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Change locations from yylloc to appropriate tokens positions.Sir Anthony2014-03-081-101/+114
| | | | Reviewed-by: Carl Worth <[email protected]>
* glsl: parse invocations layout qualifier for ARB_gpu_shader5Jordan Justen2014-02-201-0/+23
| | | | | | | | | | | | _mesa_glsl_parse_state in_qualifier->invocations will store the invocations count. v3: * Use in_qualifier to allow the primitive to be specied separately from the invocations count (merge_qualifiers) Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: convert GS input primitive to use ast_type_qualifierJordan Justen2014-02-201-55/+2
| | | | | | | | | | | | | | | | | | | | | | | | We introduce a new merge_in_qualifier ast_type_qualifier which allows specialized handling of merging input layout qualifiers. By merging layout qualifiers into state->in_qualifier, we allow multiple input qualifiers. For example, the primitive type can be specified specified separately from the invocations count (ARB_gpu_shader5). state->gs_input_prim_type is moved into state->in_qualifier->prim_type state->gs_input_prim_type_specified is still processed separately so we can determine when the input primitive is specified. This is important since certain scenerios are not supported until after the primitive type has been specified in the shader code. v4: * Merge with compute shader input layout qualifiers Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: rename _restrict to restrict_flagBrian Paul2014-02-121-1/+1
| | | | | | | | | | | To fix MSVC compile breakage. Evidently, _restrict is an MSVC keyword, though the docs only mention __restrict (with two underscores). Note: we may want to also rename _volatile to volatile_flag to be consistent. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74900 Reviewed-by: Ian Romanick <[email protected]>
* glsl/parser: Handle image built-in types.Francisco Jerez2014-02-121-0/+33
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/parser: Handle image memory qualifiers.Francisco Jerez2014-02-121-0/+83
| | | | | | v2: Make the "map" array static const. Reviewed-by: Paul Berry <[email protected]>
* glsl/parser: Handle the early_fragment_tests input layout qualifier.Francisco Jerez2014-02-121-1/+17
| | | | | | v2: Only allow the early_fragment_tests qualifier in fragment shaders. Reviewed-by: Paul Berry <[email protected]>
* glsl/lexer: Add new tokens for ARB_shader_image_load_store.Francisco Jerez2014-02-121-9/+11
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Keep track of type qualifiers defined by ARB_shader_image_load_store.Francisco Jerez2014-02-121-2/+2
| | | | | | | | v2: Add comment next to the read_only and write_only qualifier flags. Change temporary copies of the type qualifier mask to use uint64_t too. Reviewed-by: Paul Berry <[email protected]>
* glsl: Don't lose precision qualifiers when encountering "centroid".Kenneth Graunke2014-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mesa fails to retain the precision qualifier when parsing: #version 300 es centroid in mediump vec2 v; Consider how the parser's type_qualifier production is applied. First, the precision_qualifier rule creates a new ast_type_qualifier: <precision: mediump> Then the storage_qualifier rule creates a second one: <flags: in> and calls merge_qualifier() to fold in any previous qualifications, returning: <flags: in, precision: mediump> Finally, the auxiliary_storage_qualifier creates one for "centroid": <flags: centroid> it then does $$ = $1 and $$.flags |= $2.flags, resulting in: <flags: centroid, in> Since precision isn't stored in the flags bitfield, it is lost. We need to instead call merge_qualifier to combine all the fields. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reported-by: Kevin Rogovin <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/cs: Handle compute shader local_size_{x,y,z} declaration.Paul Berry2014-02-051-21/+73
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: remove remaining is_array variablesTimothy Arceri2014-01-231-15/+15
| | | | | | | | | Previously the reason we needed is_array was because we used array_size == NULL to represent both non-arrays and unsized arrays. Now that we use a non-NULL array_specifier to represent an unsized array, is_array is redundant. Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add ARB_arrays_of_arrays support to yacc definition and astTimothy Arceri2014-01-231-72/+56
| | | | | | | Adds array specifier object to hold array information Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Simplify aggregate type inference to prepare for ARB_arrays_of_arrays.Paul Berry2014-01-221-27/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the time it is not necessary to perform type inference to compile GLSL; the type of every expression can be inferred from the contents of the expression itself (and previous type declarations). The exception is aggregate initializers: their type is determined by the LHS of the variable being assigned to. For example, in the statement: mat2 foo = { { 1, 2 }, { 3, 4 } }; the type of { 1, 2 } is only known to be vec2 (as opposed to, say, ivec2, uvec2, int[2], or a struct) because of the fact that the result is being assigned to a mat2. Previous to this patch, we handled this situation by doing some type inference during parsing: when parsing a declaration like the one above, we would call _mesa_set_aggregate_type(), which would infer the type of each aggregate initializer and store it in the corresponding ast_aggregate_initializer::constructor_type field. Since this happened at parse time, we couldn't do the type inference using glsl_type objects; we had to use ast_type_specifiers, which are much more awkward to work with. Things are about to get more complicated when we add support for ARB_arrays_of_arrays. This patch simplifies things by postponing the call to _mesa_set_aggregate_type() until ast-to-hir time, when we have access to glsl_type objects. As a side benefit, we only need to have one call to _mesa_set_aggregate_type() now, instead of six. Reviewed-by: Matt Turner <[email protected]>
* mesa: Clean up nomenclature for pipeline stages.Paul Berry2014-01-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we had an enum called gl_shader_type which represented pipeline stages in the order they occur in the pipeline (i.e. MESA_SHADER_VERTEX=0, MESA_SHADER_GEOMETRY=1, etc), and several inconsistently named functions for converting between it and other representations: - _mesa_shader_type_to_string: gl_shader_type -> string - _mesa_shader_type_to_index: GLenum (GL_*_SHADER) -> gl_shader_type - _mesa_program_target_to_index: GLenum (GL_*_PROGRAM) -> gl_shader_type - _mesa_shader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string This patch tries to clean things up so that we use more consistent terminology: the enum is now called gl_shader_stage (to emphasize that it is in the order of pipeline stages), and the conversion functions are: - _mesa_shader_stage_to_string: gl_shader_stage -> string - _mesa_shader_enum_to_shader_stage: GLenum (GL_*_SHADER) -> gl_shader_stage - _mesa_program_enum_to_shader_stage: GLenum (GL_*_PROGRAM) -> gl_shader_stage - _mesa_progshader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string In addition, MESA_SHADER_TYPES has been renamed to MESA_SHADER_STAGES, for consistency with the new name for the enum. Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename the "target" field of _mesa_glsl_parse_state and the "target" parameter of _mesa_shader_stage_to_string to "stage". Reviewed-by: Brian Paul <[email protected]>
* glsl: Replace _mesa_glsl_parser_targets enum with gl_shader_type.Paul Berry2013-12-171-4/+4
| | | | | | These enums were redundant. Reviewed-by: Brian Paul <[email protected]>
* glsl: Add frontend support for `sample` auxiliary storage qualifierChris Forbes2013-12-071-2/+7
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: Implement parser support for atomic counters.Francisco Jerez2013-11-071-2/+11
| | | | | | | | | | | | | | | | 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: Move layout(location) checks to AST-to-HIR conversionIan Romanick2013-10-301-19/+15
| | | | | | | | | | | | | This will simplify the addition of layout(location) qualifiers for separate shader objects. This was validated with new piglit tests arb_explicit_attrib_location/1.30/compiler/not-enabled-01.vert and arb_explicit_attrib_location/1.30/compiler/not-enabled-02.vert. v2: Refactor error checking to check_explicit_attrib_location_allowed and eliminate the gotos. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>