summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* mesa: add GL_ARB_shader_atomic_counter_ops supportIlia Mirkin2016-03-104-0/+116
| | | | | 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]>
* glsl: report correct number of allowed vertex inputs and fragment outputsIago Toral Quiroga2016-03-101-3/+4
| | | | | | | | | | | | Before we would always report 16 for both and we would only fail if either one exceeded 16. Now we fail if the maximum for each is exceeded, even if it is smaller than 16 and we report the correct maximum. Also, expand the size of to_assign[] to 32. There is code at the top of the function handling max_index up to 32, so this just makes the code more consistent. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: dont allow undefined array sizes in ESTimothy Arceri2016-03-091-0/+12
| | | | | | | | | | This applies the rule to empty declarations. Fixes: dEQP-GLES3.functional.shaders.arrays.invalid.empty_declaration_without_var_name_vertex dEQP-GLES3.functional.shaders.arrays.invalid.empty_declaration_without_var_name_fragment Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: don't always reject shaders with mismatching ifc blocksTimothy Arceri2016-03-091-6/+72
| | | | | | | | | Since we store some member qualifiers in the interface type we need to be more careful about rejecting shaders just because the pointer doesn't match. Its perfectly valid for some qualifiers such as precision to not match across shader interfaces. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: make interstage_match() staticTimothy Arceri2016-03-091-1/+1
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: don't validate ifc blocks using validation meant for variablesTimothy Arceri2016-03-091-2/+8
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Add a pass for lower indirect variable dereferencesJason Ekstrand2016-03-084-0/+243
| | | | | | | | This new pass lowers load/store_var intrinsics that act on indirect derefs to if-ladder of direct load/store_var intrinsics. The if-ladders perform a simple binary search on the indirect. Reviewed-by: Connor Abbott <[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]>
* glsl: Add function parameters to the parser symbol table.Kenneth Graunke2016-03-071-0/+2
| | | | | | | | | | | | | | | | | | | In a shader such as: struct S { float f; } float identity(float S) { return S; } we would think that "S" in "return S" referred to a structure, even though it's shadowed by the "float S" parameter in the inner struct. This led to the parser's grammar seeing TYPE_IDENTIFIER and getting confused. Fixes dEQP-GLES2.functional.shaders.scoping.valid. function_parameter_hides_struct_type_{vertex,fragment}. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Add single declaration variables to the symbol table too.Kenneth Graunke2016-03-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | The lexer/parser use a symbol table to classify identifiers as variables, functions, or structure types. For some reason, we neglected to add variables in simple declarations such as int x = 5; but did add subsequent variables in multi-declarations: int x = 5, y = 6; // y gets added, but not x, for some reason Fixes four dEQP-GLES2.functional.shaders.scoping.valid subcases: - local_int_variable_hides_struct_type_vertex - local_int_variable_hides_struct_type_fragment - local_struct_variable_hides_struct_type_vertex - local_struct_variable_hides_struct_type_fragment Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: avoid stack smashing when there are too many attributesIlia Mirkin2016-03-071-0/+7
| | | | | | | | | | | | | | This fixes a crash in dEQP-GLES3.functional.transform_feedback.array_element.separate.points.lowp_mat3x2 and likely others. The vertex shader has > 16 input variables (without explicit locations), which causes us to index outside of the to_assign array. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: "11.1 11.2" <[email protected]>
* glsl: replace remaining tabs in link_varyings.cppTimothy Arceri2016-03-051-9/+9
| | | | Reviewed-by: Thomas Helland <[email protected]>
* glsl: replace remaining tabs in link_uniforms.cppTimothy Arceri2016-03-051-69/+69
| | | | Reviewed-by: Thomas Helland <[email protected]>
* glsl: apply align layout qualifier rules to block offsetsTimothy Arceri2016-03-051-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers) of the OpenGL 4.50 spec: "The align qualifier makes the start of each block member have a minimum byte alignment. It does not affect the internal layout within each member, which will still follow the std140 or std430 rules. The specified alignment must be a power of 2, or a compile-time error results. The actual alignment of a member will be the greater of the specified align alignment and the standard (e.g., std140) base alignment for the member's type. The actual offset of a member is computed as follows: If offset was declared, start with that offset, otherwise start with the next available offset. If the resulting offset is not a multiple of the actual alignment, increase it to the first offset that is a multiple of the actual alignment. This results in the actual offset the member will have. When align is applied to an array, it affects only the start of the array, not the array's internal stride. Both an offset and an align qualifier can be specified on a declaration. The align qualifier, when used on a block, has the same effect as qualifying each member with the same align value as declared on the block, and gets the same compile-time results and errors as if this had been done. As described in general earlier, an individual member can specify its own align, which overrides the block-level align, but just for that member. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: parse align layout qualifierTimothy Arceri2016-03-053-0/+26
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: use explicit offset when lowering buffer accessTimothy Arceri2016-03-051-0/+4
| | | | Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: copy explicit offset to uniform storageTimothy Arceri2016-03-053-0/+20
| | | | Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: update comment on offset fieldTimothy Arceri2016-03-051-1/+1
| | | | | | | The old comment was for the location not the offset, we now use the field for block members so mention that also. Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: add offset to glsl interface typeTimothy Arceri2016-03-054-0/+18
| | | | | | | | | | | | | | | | In this patch we also copy the offset value from the ast and implement offset linking rules by adding it to the record_compare() function. From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers) of the GLSL 4.50 spec: "Two blocks linked together in the same program with the same block name must have the exact same set of members qualified with offset and their integral-constant-expression values must be the same, or a link-time error results." Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: apply compile-time rules for the offset layout qualifierTimothy Arceri2016-03-051-0/+49
| | | | | | | | | | | | | | | | | | | | | | | This implements the rules for the offset qualifier on block members. From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers) of the GLSL 4.50 spec: "The offset qualifier can only be used on block members of blocks declared with std140 or std430 layouts." ... "It is a compile-time error to specify an offset that is smaller than the offset of the previous member in the block or that lies within the previous member of the block." ... "The specified offset must be a multiple of the base alignment of the type of the block member it qualifies, or a compile-time error results." Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: enable offset layout qualifier for ARB_enhanced_layoutsTimothy Arceri2016-03-051-1/+2
| | | | Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: reject invalid input layout qualifiersTimothy Arceri2016-03-051-0/+29
| | | | | | | | | | | Global in validation is already handled, this will do the validation for variables, blocks and block members. This fixes some CTS tests for the new enhanced layouts transform feedback qualifiers. V2: add some more valid input flags Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: only apply default stream to output blocksTimothy Arceri2016-03-051-1/+2
| | | | | | This is needed to allow invalid qualifier checks on inputs. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: rework parsing of blocksTimothy Arceri2016-03-052-32/+24
| | | | | | | | | | | Previously interface blocks were giving the global default flags of uniform blocks. This meant we could not check for invalid qualifiers on interface blocks because they always contained invalid flags. This changes parsing so that interface blocks now get an empty set of layouts. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: don't apply uniform/buffer layouts to interface blocksTimothy Arceri2016-03-051-6/+7
| | | | | | | | If the following patch we will stop setting these layouts by default on interface blocks, so we need to do this to avoid hitting the assert. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Recognize open-coded extract_u16.Matt Turner2016-03-041-0/+5
| | | | | | | | No shader-db changes, but does recognize some extract_u16 which enables the next patch to optimize some code. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Recognize open-coded extract_u8.Matt Turner2016-03-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two shaders that appear in Unigine benchmarks (Heaven and Valley) unpack three bytes from an integer and convert each into a float: float((val >> 16u) & 0xffu) float((val >> 8u) & 0xffu) float((val >> 0u) & 0xffu) Instead of shifting, masking, and type converting like this: shr(8) g15<1>UD g25<8,8,1>UD 0x00000010UD and(8) g16<1>UD g15<8,8,1>UD 0x000000ffUD mov(8) g17<1>F g16<8,8,1>UD shr(8) g18<1>UD g25<8,8,1>UD 0x00000008UD and(8) g19<1>UD g18<8,8,1>UD 0x000000ffUD mov(8) g20<1>F g19<8,8,1>UD and(8) g21<1>UD g25<8,8,1>UD 0x000000ffUD mov(8) g22<1>F g21<8,8,1>UD i965 can simply extract a byte and convert to float in a single instruction: mov(8) g17<1>F g25.2<32,8,4>UB mov(8) g20<1>F g25.1<32,8,4>UB mov(8) g22<1>F g25.0<32,8,4>UB This patch implements the first step: recognizing byte extraction. A later patch will optimize out the conversion to float. instructions in affected programs: 28568 -> 27450 (-3.91%) helped: 7 cycles in affected programs: 210076 -> 203144 (-3.30%) helped: 7 This patch decreases the number of instructions in the two Unigine programs by: #1721: 4520 -> 4374 instructions (-3.23%) #1706: 3752 -> 3582 instructions (-4.53%) Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Improve the accuracy of the acos() approximation.Francisco Jerez2016-03-031-1/+1
| | | | | | | | | | | | | | | | The adjusted polynomial coefficients come from the numerical minimization of the L2 norm of the relative error. The old coefficients would give a maximum relative error of about 15000 ULP in the neighborhood around acos(x) = 0, the new ones give a relative error bounded by less than 2000 ULP in the same neighborhood. Fixes four dEQP subtests: dEQP-GLES31.functional.shaders.builtin_functions.precision.acos. highp_compute.{scalar,vec2,vec3,vec4} Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: Parameterize asin_expr() on the fit coefficients.Kenneth Graunke2016-03-031-6/+6
| | | | | | | | | | | | This will allow us to share the implementation while using different polynomials for asin() and acos(). Francisco Jerez did this in the SPIR-V front-end; I'm merely porting his idea to the GLSL world. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl/opt_array_splitting: Fix indentationIago Toral Quiroga2016-03-031-28/+26
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* glsl/opt_array_splitting: Fix crash when doing array indexing into other arraysIago Toral Quiroga2016-03-031-2/+12
| | | | | | | | | | | | | | | | | | | When we find indirect indexing into an array, the current implementation of the array spliiting optimization pass does not look further into the expression tree. However, if the variable expression involves variable indexing into other arrays, we can miss that these other arrays also have variable indexing. If that happens, the pass will crash later on after hitting an assertion put there to ensure that split arrays are in fact always indexed via constants: shader_runner: opt_array_splitting.cpp:296: void ir_array_splitting_visitor::split_deref(ir_dereference**): Assertion `constant' failed. This patch fixes the problem by letting the pass step into the variable index expression to identify these cases properly. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89607 Reviewed-by: Timothy Arceri <[email protected]>
* glsl: replace remaining tabs in ir_builder.cppTimothy Arceri2016-03-031-6/+6
| | | | Reviewed-by: Thomas Helland <[email protected]>
* glsl: Initialize gl_shader_program::EmptyUniformLocations.Matt Turner2016-03-011-1/+0
| | | | | | | | | Commit 65dfb30 added exec_list EmptyUniformLocations, but only initialized the list if ARB_explicit_uniform_location was enabled, leading to crashes if the extension was not available. Cc: "11.2" <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* Android: glsl: fix dependence on YACC_HEADER_SUFFIX from build systemRob Herring2016-02-291-0/+2
| | | | | | | | | | The makefile was implicitly picking up YACC_HEADER_SUFFIX from the Android build system, but this variable is now gone. Add it locally to fix the build with AOSP master. Cc: "11.1 11.2" <[email protected]> Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* Android: fix build break from nir/glsl move to compiler/Rob Herring2016-02-293-3/+6
| | | | | | | | | | | | | | | | Commits a39a8fbbaa12 ("nir: move to compiler/") and eb63640c1d38 ("glsl: move to compiler/") broke Android builds. Fix them. There is also a missing dependency between generated NIR headers and several libraries. This isn't a new issue, but seems to have been exposed by the NIR move. Built with i915, i965, freedreno, r300g, r600g, vc4, and virgl enabled. Cc: "11.2" <[email protected]> Cc: Mauro Rossi <[email protected]> Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* mesa: add GL_OES_gpu_shader5 and GL_EXT_gpu_shader5 supportIlia Mirkin2016-02-276-57/+90
| | | | | | | | | | | 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: Consider ubo_load to be a horizontal operation.Matt Turner2016-02-251-0/+1
| | | | | | | | | | Unclear to me whether it actually is a horizontal operation that cannot be vectorized, but the fact that i965 generates the same code in either case makes me less interested in finding out. Cc: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94199 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/ast: Implicit conversion from double to float is not allowedAndres Gomez2016-02-251-4/+3
| | | | | | | | Also, renamed get_conversion_operation to avoid future misunderstandings. Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Detect do-while-false loops and unroll themIan Romanick2016-02-241-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously loops like do { // ... } while (false); that did not have any other loop-branch instructions would not be unrolled. This is commonly used to wrap multiline preprocessor macros. This produces IR like (loop ( ... break )) Since limiting_terminator was NULL, the loop unroller would throw up its hands and say, "I don't know how many iterations. How can I unroll this?" We can detect this another way. If there is no limiting_terminator and the only loop-branch is a break as the last IR, there's only one iteration. On my very old checkout of shader-db, this removes a loop from Orbital Explorer, but it does not otherwise affect the shader. The loop removed is the one the compiler inserts surrounding the switch statement. This change does prevent some seriously bad code generation in some patches to meta shaders that I recently sent out for review. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Implement the required built-in functions when OES_shader_image_atomic ↵Francisco Jerez2016-02-221-18/+43
| | | | | | | | | | | | | | | | | | | | | | is enabled. This is basically just the same atomic functions exposed by ARB_shader_image_load_store, with one exception: "highp float imageAtomicExchange( coherent IMAGE_PARAMS, float data);" There's no float atomic exchange overload in the original ARB_shader_image_load_store or GL 4.2, so this seems like new functionality that requires specific back-end support and a separate availability condition in the built-in function generator. v2: Move image availability predicate logic into a separate static function for clarity. Had to pull out the image_function_flags enum from the builtin_builder class for that to be possible. Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Add usual extension boilerplate for OES_shader_image_atomic.Francisco Jerez2016-02-223-0/+6
| | | | | | v2: No need for extension enable bits (Ilia). Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: fix emit_inline_matrix_constructor for doublesIago Toral Quiroga2016-02-191-6/+13
| | | | | | | Specifically, for the case where we initialize a dmat with a source matrix that has fewer columns/rows. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Mark float constants as suchIago Toral Quiroga2016-02-191-5/+5
| | | | | | So we don't generate double to float conversion code Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix indentation in emit_inline_matrix_constructorIago Toral Quiroga2016-02-191-75/+75
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix standalone compilerRob Clark2016-02-191-0/+12
| | | | | | | | | Need to set some non-zero limits for MaxCombinedUniformComponents, otherwise we hit an "Too many <type> shader uniform components" error in the linker. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: fix new gcc6 warningsRob Clark2016-02-181-2/+2
| | | | | | | | | | | | src/compiler/glsl/lower_discard_flow.cpp:79:1: warning: ‘ir_visitor_status {anonymous}::lower_discard_flow_visitor::visit_enter(ir_loop_jump*)’ defined but not used [-Wunused-function] lower_discard_flow_visitor::visit_enter(ir_loop_jump *ir) ^~~~~~~~~~~~~~~~~~~~~~~~~~ The base class method that was intended to be overridden was 'visit(ir_loop_jump *ir)', not visit_enter(). Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Ian Romanick <[email protected]>