summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* linker: Trivial coding standards fixesIan Romanick2016-11-091-15/+13
| | | | | | | | | v2: Revert the unreachable to assert in parcel_out_uniform_storage::visit_field. Suggested by Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Add some comments to methods of ir_variable_refcount_visitorIan Romanick2016-11-091-0/+6
| | | | | | | | | | It was not obvious from the just the .h file what the hash table contained. It was also not obvious that get_variable_entry would create a new entry in the hash table. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/cache: correct asprintf error handlingNicolai Hähnle2016-11-041-3/+3
| | | | | | | | | | | From the manpage of asprintf: "If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp are undefined." Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: fix lowering of UBO references of named blocksNicolai Hähnle2016-11-031-5/+5
| | | | | | | | | | | | | | When a UBO reference has the form block_name.foo where block_name refers to a block where the first member has a non-zero offset, the base offset was incorrectly added to the reference. Fixes an assertion triggered in debug builds by GL45-CTS.enhanced_layouts.uniform_block_layout_qualifier_conflict. That test doesn't properly check for correct execution in this case, so I am also going to send out a piglit test. Cc: 13.0 <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Update deref types when resizing implicitly sized arrays.Kenneth Graunke2016-11-031-23/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | At link time, we resolve the size of implicitly sized arrays. When doing so, we update the type of the ir_variables. However, we neglected to update the type of ir_dereference nodes which reference those variables. It turns out array_resize_visitor (for GS/TCS/TES interface array handling) already did 2/3 of the cases for this, so we can simply refactor the code and reuse it. This fixes: GL45-CTS.shader_storage_buffer_object.basic-syntax GL45-CTS.shader_storage_buffer_object.basic-syntaxSSO which have an SSBO containing an implicitly sized array, followed by some other members. setup_buffer_access uses the dereference types to compute offsets to fields, and it had a stale type where the implicitly sized array's length was still 0 instead of the actual length. While we're here, we can also fix update_array_sizes to properly update deref types as well, fixing a FINISHME from 2010. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa/glsl: delete previously linked shaders earlier when linkingTimothy Arceri2016-11-034-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves the delete linked shaders call to _mesa_clear_shader_program_data() which makes sure we delete them before returning due to any validation problems. It also reduces some code duplication. From the OpenGL 4.5 Core spec: "If LinkProgram failed, any information about a previous link of that program object is lost. Thus, a failed link does not restore the old state of program. ... If one of these commands is called with a program for which LinkProgram failed, no error is generated unless otherwise noted. Implementations may return information on variables and interface blocks that would have been active had the program been linked successfully. In cases where the link failed because the program required too many resources, these commands may help applications determine why limits were exceeded." Therefore it's expected that we shouldn't be able to query the program that failed to link and retrieve information about a previously successful link. Before this change the linker was doing validation before freeing the previously linked shaders and therefore could exit on failure before they were freed. This change also fixes an issue in compat profile where a program with no shaders attached is expect to fall back to fixed function but was instead trying to relink IR from a previous link. Reviewed-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97715 Cc: "13.0" <[email protected]>
* glsl: compute lvalues of [in]out parameters before inlined function bodyNicolai Hähnle2016-11-021-10/+81
| | | | | | | | | | | | | | | This is required when an out argument involves an array index that is either a global variable modified by the function or another out argument in the same function call. Fixes the shaders/out-parameter-indexing/vs-inout-index-inout-* tests. v2: - modify the ir_dereference_array nodes in place - use ir_hierarchical_visitor v3: use base_ir (Ian Romanick) Reviewed-by: Ian Romanick <[email protected]>
* glsl: use a non-malloc'd storage for short ir_variable namesMarek Olšák2016-10-313-3/+22
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_constant_propagationMarek Olšák2016-10-311-3/+11
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_copy_propagationMarek Olšák2016-10-311-1/+6
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_copy_propagation_elementsMarek Olšák2016-10-311-4/+11
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_dead_code_localMarek Olšák2016-10-311-3/+9
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in glsl_symbol_tableMarek Olšák2016-10-311-8/+8
| | | | | | | no ralloc_free occurences Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator for ast_node and derived classesMarek Olšák2016-10-316-113/+114
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/lexer: use the linear allocatorMarek Olšák2016-10-313-8/+12
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[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)
* ralloc: use rzalloc where it's necessaryMarek Olšák2016-10-315-6/+6
| | | | | | | | | | | | | | | | | No change in behavior. ralloc_size is equivalent to rzalloc_size. That will change though. Calls not switched to rzalloc_size: - ralloc_vasprintf - glsl_type::name allocation (it's filled with snprintf) - C++ classes where valgrind didn't show uninitialized values I switched most of non-glsl stuff to rzalloc without checking whether it's really needed. Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* 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: Fix reading of uninitialized memoryJuha-Pekka Heikkila2016-10-311-2/+2
| | | | | | | | | | Switch to use memory allocations which zero memory for places where needed. v2: modify and rebase on top of Marek's series (Tapani) Signed-off-by: Juha-Pekka Heikkila <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: Improve accuracy of alpha scaling in advanced blend lowering.Kenneth Graunke2016-10-281-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When blending with GL_COLORBURN_KHR and these colors: dst = <0.372549027, 0.372549027, 0.372549027, 0.372549027> src = <0.09375, 0.046875, 0.0, 0.375> the normalized dst value became 0.99999994 (due to precision problems in the floating point divide of rgb by alpha). This caused the color burn equation to fail the dst >= 1.0 comparison. The blue channel would then fall through to the dst < 1.0 && src >= 0 comparison, which was true, since src.b == 0. This produced a factor of 0.0 instead of 1.0. This is an inherent numerical instability in the color burn and dodge equations - depending on the precision of alpha scaling, the value can be either 0.0 or 1.0. Technically, GLSL floating point division doesn't even guarantee that 0.372549027 / 0.372549027 = 1.0. So arguably, the CTS should allow either value. I've filed a bug at Khronos for further discussion (linked below). In the meantime, this patch improves the precision of alpha scaling by replacing the division with (rgb == alpha ? 1.0 : rgb / alpha). We may not need this long term, but for now, it fixes the following CTS tests: ES31-CTS.blend_equation_advanced.blend_specific.GL_COLORBURN_KHR ES31-CTS.blend_equation_advanced.blend_all.GL_COLORBURN_KHR_all_qualifier Cc: [email protected] Cc: [email protected] Bugzilla: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=16042 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: Size TCS->TES unsized arrays to gl_MaxPatchVertices for queries.Kenneth Graunke2016-10-274-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSO validation and other program interface queries want to see that unsized (non-patch) TCS output/TES input arrays are implicitly sized to gl_MaxPatchVertices. By the time we create the program resource lists, we've sized the arrays to their actual size. (We try to create TCS output arrays to match the output patch size right away, and at this point, we should have shrunk TES input arrays.) One option would be to keep them sized to gl_MaxPatchVertices, and defer shrinking them. But that's a big change, and I don't think it's a good idea. Instead, this patch introduces a new ir_variable flag which indicates the variable is implicitly to gl_MaxPatchVertices. Then, the linker munges the types when creating the resource list, ignoring the size in the IR's types. Basically, lie about it for resource queries. It's ugly, but I think it ought to work. We probably could use var->data.implicit_sized_array for this, but I opted for a separate bit to try and avoid convoluting the existing SSBO handling. They're similar in concept, but share none of the same code... Fixes: ES31-CTS.core.tessellation_shader.single.xfb_captures_data_from_correct_stage and the ES32-CTS and ESEXT-CTS variants. v2: Add a comment (requested by Timothy, written by me). Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Pass ctx to program interface query helper functions.Kenneth Graunke2016-10-271-13/+20
| | | | | | | | | | The next commit will use this in add_shader_variable - this just separates out some of the mechanical changes for easier review. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: update default precision qualifier when it is set in the shaderSamuel Iglesias Gonsálvez2016-10-261-1/+4
| | | | | | | | | | | | Default precision qualifier for a data type could be set several times inside a shader. This patch allows to update the default precision qualifier for the given type that is saved in the symbol table. If it is not in the symbol table, just add it. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97804 Reviewed-by: Timothy Arceri <[email protected]>
* glsl: set uses texture gather directly in shader_infoTimothy Arceri2016-10-261-1/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/st/mesa: use common system values read fieldTimothy Arceri2016-10-261-2/+2
| | | | | | | | | And set system values read directly in shader_info. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set patch outputs written directly in shader_infoTimothy Arceri2016-10-261-2/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set patch inputs read directly in shader_infoTimothy Arceri2016-10-261-2/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set outputs read directly in shader_infoTimothy Arceri2016-10-261-2/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* r200/glsl/st/mesa: use common outputs written fieldTimothy Arceri2016-10-261-6/+6
| | | | | | | | | And set outputs written directly in shader_info. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/glsl: set double inputs read directly in shader_infoTimothy Arceri2016-10-261-1/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* r200/i915/st/mesa/compiler: use common inputs read fieldTimothy Arceri2016-10-261-6/+6
| | | | | | | | | | | | And set set inputs_read directly in shader_info. To avoid regressions between changes this change is a squashed version of the following patches. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* i965/mesa/st/swrast: set fs shader_info directly and switch to using itTimothy Arceri2016-10-261-10/+4
| | | | | | | Note we access shader_info from the program struct rather than the nir_shader pointer because shader cache won't create a nir_shader. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: remove now unused IsCentroid from gl_fragment_programTimothy Arceri2016-10-261-5/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: remove now unused InterpQualifierTimothy Arceri2016-10-261-5/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: add temporary copy_shader_info() functionTimothy Arceri2016-10-261-45/+0
| | | | | | | | | | | | | This function is added here to ease refactoring towards using the new shared shader_info. Once refactoring is complete and values are set directly it will be removed. We call it from _mesa_copy_linked_program_data() rather than glsl_to_nir() so that the values will be set for all drivers. In order to do this some calls need to be moved around so that we make sure to call do_set_program_inouts() before _mesa_copy_linked_program_data() Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: add a shader info field to the gl_program typeTimothy Arceri2016-10-261-1/+2
| | | | | | | | | | And use this field as the source for shader info in the nir_shader this will allow us to set some of these fields from GLSL directly. It will also simplify restoring from shader cache and allow the removal of duplicate fields from GLSL. Reviewed-by: Jason Ekstrand <[email protected]>
* nir/i965/anv/radv/gallium: make shader info a pointerTimothy Arceri2016-10-261-33/+33
| | | | | | | | | | When restoring something from shader cache we won't have and don't want to create a nir_shader this change detaches the two. There are other advantages such as being able to reuse the shader info populated by GLSL IR. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: add matrix layout information to interface block typesIago Toral Quiroga2016-10-246-2/+15
| | | | | | | | | | | | | | | | | | | | | | So far we have been checking that interface block definitions had matching matrix layouts by comparing the definitions of their fields, however, this does not cover the case where the interface blocks are defined with mismatching matrix layouts but don't define any field with a matrix type. In this case Mesa will not fail to link because none of the fields will inherit the mismatching layout qualifier. This patch fixes the problem in the same way we fixed it for packing layout information: we add the the layout information to the interface type and then we check it matches during the uniform block linking process. v2: Fix unit tests so they pass the new parameter to glsl_type::get_interface_instance() Fixes: dEQP-GLES31.functional.shaders.linkage.uniform.block.layout_qualifier_mismatch_3 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98245 Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* glsl/mesa: remove unused namespace support from the symbol tableTimothy Arceri2016-10-242-11/+11
| | | | | | | | | | | | | | | | | | Namespace support seems to have been unused for a very long time. Previously the hash table entry was never removed and the symbol name wasn't freed until the symbol table was destroyed. In theory this could reduced the number of times we need to copy a string as duplicate names are reused. However in practice there is likely only a limited number of symbols that are the same and this is likely to cause other less than optimal behaviour such as the hash_table continuously growing. Along with dropping namespace support this change removes entries from the hash table as they become unused. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl/es31: precision qualifier doesn't need to match in shader interface ↵Samuel Iglesias Gonsálvez2016-10-242-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | block members It is specific only to GLSL ES 3.1. From the spec, section 4.3.9 "Interface Blocks": "Matched block names within a shader interface (as defined above) must match in terms of having the same number of declarations with the same sequence of types and the same sequence of member names, as well as having the same qualification as specified in section 9.2 (“Matching of Qualifiers“)." But in GLSL ES 3.0 and 3.2, it is the opposite: "Matched block names within a shader interface (as defined above) must match in terms of having the same number of declarations with the same sequence of types, precisions and the same sequence of member names, as well as having the matching member-wise layout qualification as defined in section 9.2 (“Matching of Qualifiers”)." Fixes: dEQP-GLES31.functional.shaders.linkage.uniform.block.differing_precision Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98243 Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: move intrastage_match() after interstage_member_mismatch()Samuel Iglesias Gonsálvez2016-10-241-46/+46
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Indirect array indexing on non-last SSBO member must fail compilationIago Toral Quiroga2016-10-202-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the changes in comit 5b2675093e863a52, we moved this check to the linker, but the spec expects this to be checked at compile-time. There are dEQP tests that expect an error at compile time and the spec seems to confirm that expectation: "Except for the last declared member of a shader storage block (section 4.3.9 “Interface Blocks”), the size of an array must be declared (explicitly sized) before it is indexed with anything other than an integral constant expression. The size of any array must be declared before passing it as an argument to a function. Violation of any of these rules result in compile-time errors. It is legal to declare an array without a size (unsized) and then later redeclare the same name as an array of the same type and specify a size, or index it only with integral constant expressions (implicitly sized)." Commit 5b2675093e863a52 tries to take care of the case where we have implicitly sized arrays in SSBOs and it does so by checking the max_array_access field in ir_variable during linking. In this patch we change the approach: we look for indirect access on SSBO arrays, and when we find one, we emit a compile-time error if the accessed member is not the last in the SSBO definition. There is a corner case that the specs do not address directly though and that dEQP checks for: the case of an unsized array in an SSBO definition that is not defined last but is never used in the shader code either. The following dEQP tests expect a compile-time error in this scenario: dEQP-GLES31.functional.debug.negative_coverage.callbacks.shader.compile_compute_shader dEQP-GLES31.functional.debug.negative_coverage.get_error.shader.compile_compute_shader dEQP-GLES31.functional.debug.negative_coverage.log.shader.compile_compute_shader However, since the unsized array is never used it is never indexed with a non-constant expression, so by the spec quotation above, it should be valid and the tests are probably incorrect. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Remove unused function import_prototypesIan Romanick2016-10-172-131/+0
| | | | | | | | | | Once upon a time, this was used to extract prototypes from the shader containing GLSL built-in functions. This was removed by f5692f45 in November 2010 for Mesa 7.10. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl: Remove prototypes for nonexistent functionsIan Romanick2016-10-171-9/+0
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl: Replace assert with unreachableIan Romanick2016-10-171-1/+2
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl: print non-zero bindings of variablesNicolai Hähnle2016-10-171-2/+6
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glsl: fail compilation of compute shaders when unsupportedIago Toral Quiroga2016-10-171-0/+13
| | | | | | | | | | | | | | | | | | | | | | | Generally, we only check for the presence of compute shaders during parsing when we find any language (like layout qualifiers) that are specific to compute shaders, however, it is possible to define an empty compute shader does not use any language specific to compute shaders at all and we should fail the compilation anyway. dEQP checks this. This patch adds a check for compute shader availability after we have parsed the source code. At this point we know the effective GLSL version and also extensions enabled in the shader. Fixes a subcase of the following dEQP tests: dEQP-GLES31.functional.debug.negative_coverage.callbacks.shader.compile_compute_shader dEQP-GLES31.functional.debug.negative_coverage.get_error.shader.compile_compute_shader dEQP-GLES31.functional.debug.negative_coverage.log.shader.compile_compute_shader The tests still fail because there is one more subcase that fails that needs another fix. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Disable textureOffset(sampler2DArrayShadow, ...) in GLSL ES.Kenneth Graunke2016-10-161-1/+7
| | | | | | | | | | | | This has apparently never existed in GLSL ES. Fixes dEQP-GLES3.functional.shaders.texture_functions.invalid .textureoffset_sampler2darrayshadow_vec4_ivec2_vertex and .textureoffset_sampler2darrayshadow_vec4_ivec2_fragment Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98244 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Drop the ES requirement that VS outputs must be flat qualified.Kenneth Graunke2016-10-151-8/+4
| | | | | | | | | | | | | | | | | | | Several conformance tests violate this requirement: ES31-CTS.core.tessellation_shader.max_patch_vertices ES31-CTS.core.tessellation_shader.tessellation_control_to_tessellation_evaluation.data_pass_through I submitted a merge request to fix the conformance tests, but Khronos opted to drop this GLSL ES specific requirement in favor of making flat qualification of VS outputs optional, matching modern desktop GL. Note that there were 7 Piglit tests which enforce this rule: tests/spec/glsl-es-3.00/compiler/interpolation/qualifiers/*nonflat* but these were deleted in Piglit commit acc0a2fabbd714bc704c16f1675e7c0. Bugzilla: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15465#c7 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: dump explicit location when printing IRNicolai Hähnle2016-10-121-3/+7
| | | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Dave Airlie <[email protected]>