summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast.h
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Remove unused ast copy constructors.Matt Turner2014-11-241-29/+0
| | | | | | | | | These were added in commits a760c738 and 43757135 to be used in implementing C-style aggregate initializers (commit 1b0d6aef). Paul rewrote that code in commit 0da1a2cc to use GLSL types, rather than AST types, leaving these copy constructors unused. Tested by making them private and providing no definition.
* glsl: Add parsing support for multi-stream output in geometry shaders.Samuel Iglesias Gonsalvez2014-06-301-0/+5
| | | | | | | | 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: Add support for `precise` redeclarationsChris Forbes2014-06-041-6/+4
| | | | | | | | 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-0/+1
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Skip making a temporary for assignments when we don't need one.Eric Anholt2014-04-081-0/+13
| | | | | | | | | | | | | | | | | | While we wish our optimization passes could identify all the cases where we can coalesce our variables, we miss out on a lot of opportunities. total instructions in shared programs: 1673849 -> 1673166 (-0.04%) instructions in affected programs: 299521 -> 298838 (-0.23%) GAINED: 7 LOST: 0 Note that many programs are "hurt". The notable ones are where we produce unrolling in cases we didn't before (presumably just because of the lower instruction count). But there are also some cases where pushing things right into the variables prevents copy propagation and tree grafting, since we don't split our variable usage webs apart. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add ast_node method to set location range.Sir Anthony2014-03-081-0/+14
| | | | Reviewed-by: Carl Worth <[email protected]>
* glsl: Make ast_node location comments more informative.Sir Anthony2014-03-081-4/+4
| | | | Reviewed-by: Carl Worth <[email protected]>
* glsl: Extend ast location structure to hande end token position.Sir Anthony2014-03-081-9/+13
| | | | Reviewed-by: Carl Worth <[email protected]>
* glsl: removed unused dimension_count varibleTimothy Arceri2014-02-261-6/+2
| | | | | | | | This variable is no longer needed after the cleanup to the code prior to the first arrays of array series Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: parse invocations layout qualifier for ARB_gpu_shader5Jordan Justen2014-02-201-0/+8
| | | | | | | | | | | | _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-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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/ast: Keep track of type qualifiers defined by ARB_shader_image_load_store.Francisco Jerez2014-02-121-1/+31
| | | | | | | | 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/cs: Handle compute shader local_size_{x,y,z} declaration.Paul Berry2014-02-051-0/+34
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: Make condition_to_hir() callable from outside ast_iteration_statement.Paul Berry2014-02-041-2/+1
| | | | | | | | | | | | | | | | In addition to making it public, we also need to change its first argument from an ir_loop * to an exec_list *, so that it can be used to insert the condition anywhere in the IR (rather than just in the body of the loop). This will be necessary in order to make continue statements work properly in do-while loops. Cc: [email protected] Acked-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: remove remaining is_array variablesTimothy Arceri2014-01-231-25/+7
| | | | | | | | | 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-14/+52
| | | | | | | 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-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* glsl: Add frontend support for `sample` auxiliary storage qualifierChris Forbes2013-12-071-0/+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-0/+15
| | | | | | | | | | | | | | | | 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: Switch ast_type_qualifier to the non-zeroing allocator.Francisco Jerez2013-10-011-1/+1
| | | | | | | | All member variables of ast_type_qualifier are already being initialized from its implicitly defined constructor, it's not necessary to use rzalloc to allocate its memory. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Switch ast_node to the non-zeroing allocator.Francisco Jerez2013-10-011-1/+9
| | | | | | | | | | | | | | | | | | All member variables of ast_node are already being initialized from its constructor, but some of its derived classes were leaving members uninitialized -- Fix them. Using rzalloc makes it more likely that we will start relying on the allocator to zero out all memory if the class is ever extended with new member variables. That's bad because it ties objects to some specific allocation scheme, and gives unpredictable results when an object is created with a different allocator -- Stack allocation, array allocation, or aggregation inside a different object are some of the useful possibilities that come to my mind. v2: Use NULL initialization instead of default construction for pointers. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Use the new DECLARE_R[Z]ALLOC_CXX_OPERATORS in a bunch of places.Kenneth Graunke2013-09-211-36/+2
| | | | | | | | | This eliminates a lot of boilerplate and should be 100% equivalent. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove ubo_qualifiers_allowed variable.Matt Turner2013-08-211-6/+0
| | | | | | | No longer used. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Rename ubo_qualifiers_valid to ubo_qualifiers_allowed.Matt Turner2013-08-211-1/+1
| | | | | | | | | The variable means that UBO qualifiers are allowed in a particular context (e.g., not allowed in a struct field declaration), rather than a particular set of UBO qualifiers are valid. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Track existence of default float precision in GLSL ES fragment shadersIan Romanick2013-08-211-0/+4
| | | | | | | | | | | | | | | | | | | This is required by the spec, and it's a bit tricky because the default precision is scoped. As a result, I'm slightly abusing the symbol table. Fixes piglit no-default-float-precision.frag tests and the piglit default-precision-nested-scope-0[1234].frag tests that are currently on the piglit mailing list for review. On IRC I got confirmation from cwabbot that ARM (Mali T6xx and T400) enforces this requirement and from kusma that NVIDIA (Tegra2) enforces this requirement. We should be safe from regressing shipping applications. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Allow geometry shader input instance arrays to be unsized.Paul Berry2013-08-011-8/+16
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Parse the GLSL 1.50 GS layout qualifiers.Eric Anholt2013-08-011-0/+34
| | | | | | | | | | | | | | | Limited semantic checking (compatibility between declarations, checking that they're in the right shader target, etc.) is done. v2: Remove stray debug printfs. v3 (Paul Berry <[email protected]>): Process input layout qualifiers at ast_to_hir time rather than at parse time, since certain error conditions depend on the relative ordering between input layout qualifiers, declarations, and calls to .length(). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Parse the "binding" keyword and store it in ast_type_qualifier.Kenneth Graunke2013-07-181-0/+14
| | | | | | | | | Nothing actually uses this yet. v2: Remove >= 0 checks. They'll be handled in later validation. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Move precision handling to be part of qualifier handling.Kenneth Graunke2013-07-181-5/+6
| | | | | | | | | This is necessary for the parser to be able to accept precision qualifiers not immediately adjacent to the type, such as "const highp inout float foo". Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Change is_precision_statement to default_precision != none.Kenneth Graunke2013-07-181-4/+5
| | | | | | | | | | | | | | | | | | | | | | Currently, we store precision in ast_type_specifier, rather than ast_type_qualifier. This works because precision is the last qualifier, and immediately adjacent to the type. Default precision statements (such as "precision highp float") are represented as ast_type_specifier objects, with a boolean to indicate that it's a default precision statement rather than an ordinary type. ast_type_specifier::precision will be moving to ast_type_qualifier soon, in order to support arbitrary qualifier ordering. However, we still need to store a "this is a precision statement" flag /and/ the default precision in ast_type_specifier. This patch changes the boolean into a new field, default_precision. If default_precision != ast_precision_none, it's a precision statement with the specified precision. Otherwise, it's an ordinary type. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add a new ast_type_qualifier::has_auxiliary_storage() method.Kenneth Graunke2013-07-181-0/+5
| | | | | | | | | | | | "Auxiliary storage qualifiers" is the new term given to "centroid", "patch", and "sample" by GLSL 4.20/GL_ARB_shading_language_420pack. Even though we only support "centroid", it's useful to add this now so that all auxiliary storage qualifiers get handled in the right places once they're eventually supported. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add a new ast_type_qualifier::has_storage() method.Kenneth Graunke2013-07-181-0/+5
| | | | | | | | | | | | | | | | This makes it easy to check if any storage qualifiers are set. "centroid" is not considered a storage qualifier. In the old language rules, you can't specify "centroid" by itself; it's always "centroid in", "centroid out", or "centroid varying." So one of the other storage qualifiers will always be set; there's no need to specifically check for centroid. In the new 4.20 rules, centroid is an auxiliary storage qualifier, not a storage qualifier. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add a new ast_type_qualifier::has_layout() method.Kenneth Graunke2013-07-181-0/+5
| | | | | | | This makes it easy to check if any layout qualifiers are set. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Initialize ast_aggregate_initializer::constructor_type.Vinson Lee2013-07-121-1/+2
| | | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add support for C-style initializers.Matt Turner2013-07-111-0/+5
| | | | | | | | | Required by GL_ARB_shading_language_420pack. Parts based on work done by Todd Previte and Ken Graunke, implementing basic support for C-style initializers of arrays. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add infrastructure for aggregate initializers.Matt Turner2013-07-111-1/+25
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add an is_declaration field to ast_struct_specifier.Matt Turner2013-07-111-1/+3
| | | | | | | | | | | | | | | | | | Will be used in a later commit to differentiate between a structure type declaration and a variable declaration of a struct type. I.e., the difference between struct S { float x; }; (is_declaration = true) and S s; (is_declaration = false) Also note that is_declaration = true for struct S { float x; } s; Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add copy-constructor for ast_struct_specifier.Matt Turner2013-07-111-0/+12
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a constructor for ast_type_specifier.Matt Turner2013-07-111-0/+16
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Change type of is_array to bool.Matt Turner2013-07-111-4/+4
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a comment to note what an exec_list is a list of.Matt Turner2013-07-111-0/+1
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: rename ast_uniform_block to ast_interface_blockJordan Justen2013-05-231-2/+2
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't early-out for error-type inputsIan Romanick2013-04-081-2/+1
| | | | | | | | | | | | | | | | | | | | Check the type of the array operand and the index operand before doing other checks. This simplifies the code a bit now (eliminating the error_emitted parameter), and enables some later functional changes. The shader uniform float x[6]; uniform sampler2D s; void main() { gl_Position.x = xx[s + 1]; } still generates (only) the two expected errors: 0:3(33): error: `xx' undeclared 0:3(39): error: Operands to arithmetic operators must be numeric Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't return a value from check_builtin_array_max_sizeIan Romanick2013-04-081-1/+1
| | | | | | | | That last consumer of the return value was changed to not use it by the previous commit. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Refactor handling of ast_array_index to a separate functionIan Romanick2013-04-081-0/+7
| | | | | | | | | I love 800+ line switch-statements as much as the next guy... Future commits will make changes to this part of the AST-to-HIR conversion, and extracting this code will make that a bit easier. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make check_build_array_max_size externally visibleIan Romanick2013-04-081-0/+4
| | | | | | | A future commit will try to use this function in a different file. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize ast_parameter_declarator member variables.Vinson Lee2013-02-051-4/+8
| | | | | | | Fixes uninitialized pointer field defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Parse interface array sizeIan Romanick2013-01-251-5/+16
| | | | | | | | | | | | | The size is parsed and stored in the AST, but it is not used yet. Processing of the array size is added in the patch "glsl: Handle instance array declarations" v2: Update the commit message (suggested by Carl Worth). Add a comment to ast_uniform_block::array_size (suggested by Paul Berry). Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Parse non-array uniform block instance names in GLSL ES 3.00.Kenneth Graunke2013-01-251-2/+12
| | | | | | | | | | | | | | | | | | | | | | | In GLSL ES 3.00 (and GLSL 1.50), uniform blocks can have an associated "instance name", which essentially namespaces the variables inside. This patch adds basic parsing for this new feature, but doesn't yet hook it up to actually do anything yet. It does not support for arrays of interface blocks; a later commit will take care of that. This change temporarily regresses the piglit test interface-name-access-without-interface-name.vert. This shader failed to compile before (the expected result), but it failed to compile for the wrong reason. This is not a real regression. v2: Add some comments to ast_uniform_block::instance_name. Suggested by Paul Berry. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>