summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* 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]>
* glsl: fix new gcc6 warningsRob Clark2016-02-181-1/+1
| | | | | | | | | | | | | | | | | | | src/compiler/glsl/ast_to_hir.cpp: In function ‘unsigned int ast_process_struct_or_iface_block_members(exec_list*, _mesa_glsl_parse_state*, exec_list*, glsl_struct_field**, bool, glsl_matrix_layout, bool, ir_variable_mode, ast_type_qualifier*, unsigned int, unsigned int)’: src/compiler/glsl/ast_to_hir.cpp:6339:52: warning: ‘first_member_has_explicit_location’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (!layout->flags.q.explicit_location && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ ((first_member_has_explicit_location && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !qual->flags.q.explicit_location) || ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (!first_member_has_explicit_location && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qual->flags.q.explicit_location))) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Disallow "defined" as a macro name.Kenneth Graunke2016-02-181-0/+3
| | | | | | | | | | Both GCC and Clang disallow this, and glslang has recently started disallowing it as well. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94188 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* compiler/glsl: Fix uniform location counting.Plamena Manolova2016-02-183-35/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch moves the calculation of current uniforms to link_uniforms, which makes use of UniformRemapTable which stores all the reserved uniform locations. Location assignment for implicit uniforms now tries to use any gaps left in the table after the location assignment for explicit uniforms. This gives us more space to store more uniforms. Patch is based on earlier patch with following changes/additions: 1: Move the counting of explicit locations to check_explicit_uniform_locations and then pass the number to link_assign_uniform_locations. 2: Count the number of empty slots in UniformRemapTable and store them in a list_head. 3: Try to find an empty slot for implicit locations from the list, if that fails resize UniformRemapTable. Fixes following CTS tests: ES31-CTS.explicit_uniform_location.uniform-loc-mix-with-implicit-max ES31-CTS.explicit_uniform_location.uniform-loc-mix-with-implicit-max-array Signed-off-by: Tapani Pälli <[email protected]> Signed-off-by: Plamena Manolova <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93696
* glsl: remove duplicate interpolation_string() functionTimothy Arceri2016-02-173-30/+2
| | | | | | | We already have one in the IR code that can be used everywhere its needed in the AST code so remove the one from the AST. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: remove unused helperTimothy Arceri2016-02-172-26/+0
| | | | | | Seems to have become unused when i965 moved to NIR. Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: set user defined varyings to smooth by default in ESTimothy Arceri2016-02-171-0/+11
| | | | | | | | | | | | | | | | This is usually handled by the backends in order to handle the various interactions with the gl_*Color built-ins. The problem is this means linking will fail if one side on the interface adds the smooth qualifier to the varying and the other side just uses the default even though they match. This fixes various deqp tests. The spec is not clear what to for desktop GL so leave it as is for now. Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92743
* glsl: warn in GL as well as ES when varying not writtenTimothy Arceri2016-02-161-16/+7
| | | | | Reviewed-by: Iago Toral Quiroga <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93339
* glsl: Fix overflow of ImageAccess[] array.Kenneth Graunke2016-02-131-3/+3
| | | | | | | | | | | | | | | | | | | | | The ImageAccess array is statically sized to MAX_IMAGE_UNIFORMS: GLenum ImageAccess[MAX_IMAGE_UNIFORMS]; There was no bounds checking ensuring we don't overflow. Passing in a shader with too many uniforms would cause writes to extend into other fields, such as sh->NumImages. Later linker checks already handle reporting an error when there are too many images, so just avoid corrupting structures here. This rearranges the logic a bit to look more like the sampler case. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Tested-by: Jordan Justen <[email protected]>
* nir/types: Add more type constructor functionsJason Ekstrand2016-02-132-0/+58
| | | | Reviewed-by: Jordan Justen <[email protected]>
* nir/types: Add a few more glsl_type_is_ functionsJason Ekstrand2016-02-132-0/+21
| | | | Reviewed-by: Jordan Justen <[email protected]>
* nir/types: Add helpers for working with sampler and image typesJason Ekstrand2016-02-132-0/+75
| | | | Reviewed-by: Jordan Justen <[email protected]>
* nir/types: Add helpers for function typesJason Ekstrand2016-02-132-0/+28
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl/types: Expose glsl_struct_field and glsl_function_param to CJason Ekstrand2016-02-131-4/+6
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl/types: Add a helper for getting image typesJason Ekstrand2016-02-132-0/+89
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl/types: Add support for function typesJason Ekstrand2016-02-136-1/+134
| | | | | | | | SPIR-V has a concept of a function type that's used fairly heavily. We could special-case function types in SPIR-V -> NIR but it's easier if we just add support to glsl_types. Reviewed-by: Jordan Justen <[email protected]>
* glsl/types: Add a bare "sampler" typeJason Ekstrand2016-02-131-0/+1
| | | | | | | | | This is to be used by SPIR-V for representing a sampler that isn't attached to any particular image. In SPIR-V, all of the interesting bits such as dimensionality, sampled type, etc. come from the image, the bare "sampler" type simply uses a sampled type of VOID and 0 values for the rest. Reviewed-by: Jordan Justen <[email protected]>
* glsl/types: Rename sampler_type to sampled_typeJason Ekstrand2016-02-136-13/+13
| | | | | | | | It's a bit more descriptive since it is the base type that you get when you sample from it. Also, the next commit adds a bare "sampler" type and we need glsl_type::sampler_type available for a public static member. Reviewed-by: Jordan Justen <[email protected]>
* mesa: do not use a constant for MAX_COMPUTE_SHARED_SIZESamuel Pitoiset2016-02-131-0/+1
| | | | | | | | | | This will allow to query the underlying drivers for the maximum total storage size of all variables declared as <shared> with PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: make compute maximums reflect driver-provided valuesIlia Mirkin2016-02-134-5/+26
| | | | | | | | Looks like the various max's were never plumbed through. Signed-off-by: Ilia Mirkin <[email protected]> Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: replace _strtoui64() with strtoull() for MSVCTimothy Arceri2016-02-131-4/+0
| | | | | | Now that MSVC 2013 is required we can remove this. Reviewed-by: Jose Fonseca <[email protected]>
* glsl: Allow invariant qualifer in block members in desktop OpenGL.Samuel Iglesias Gonsálvez2016-02-121-20/+4
| | | | | | | | | | | | | | Feedback from Khronos is that 'invariant' should be allowed on block members for desktop OpenGL. Fix piglit regression added by fe1e89a0: invariant-qualifier-in-out-block-01.vert v2: - Allow it for in/out blocks in OpenGL ES too, so when OES_shader_io_blocks is supported we don't need to do any change (Timothy) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89330 Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: don't validate interface blocks twiceTimothy Arceri2016-02-121-23/+21
| | | | | | | We already check for opaque types so don't recheck for atomics and images. Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: remove duplicate embedded struct validationTimothy Arceri2016-02-123-51/+17
| | | | | | | | | | | Commit c98deb18d5836f in 2010 disallowed embedded struct definitions in ES. Then in 2013 d9bb8b7b56ce65b disallowed it for everything but GLSL 1.10. Commit c98deb18d5836f seemed the cleanest way to do the check so its been extended to cover GL and the other version has been removed. Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: call build_program_resource_list inside Driver.LinkShaderMarek Olšák2016-02-111-1/+4
| | | | | | to allow LinkShader to free the GLSL IR. Reviewed-by: Ian Romanick <[email protected]>
* nir: Remove the const_offset from nir_tex_instrJason Ekstrand2016-02-105-32/+5
| | | | | | | | | | | When NIR was originally drafted, there was no easy way to determine if something was constant or not. The result was that we had lots of special-casing for constant values such as this. Now that load_const instructions are SSA-only, it's really easy to find constants and this isn't really needed anymore. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir/lower_vec_to_movs: Better report channels handled by insert_movJason Ekstrand2016-02-101-1/+3
| | | | | | | | | | | | | | This fixes two issues. First, we had a use-after-free in the case where the instruction got deleted and we tried to return mov->dest.write_mask. Second, in the case where we are doing a self-mov of a register, we delete those channels that are moved to themselves from the write-mask. This means that those channels aren't reported as being handled even though they are. We now stash off the write-mask before remove unneeded channels so that they still get reported as handled. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94073 Reviewed-by: Matt Turner <[email protected]> Cc: "11.0 11.1" <[email protected]>
* nir: Separate texture from sampler in nir_tex_instrJason Ekstrand2016-02-0910-18/+94
| | | | | | | | | | | | | This commit adds the capability to NIR to support separate textures and samplers. As it currently stands, glsl_to_nir only sets the texture deref and leaves the sampler deref alone as it did before and nir_lower_samplers assumes this. Backends can still assume that they are combined and only look at only at the texture index. Or, if they wish, they can assume that they are separate because nir_lower_samplers, tgsi_to_nir, and prog_to_nir all set both texture and sampler index whenever a sampler is required (the two indices are the same in this case). Reviewed-by: Kenneth Graunke <[email protected]>
* nir/tex_instr: Rename sampler to textureJason Ekstrand2016-02-0911-58/+58
| | | | | | | | | We're about to separate the two concepts. When we do, the sampler will become optional. Doing a rename first makes the separation a bit more safe because drivers that depend on GLSL or TGSI behaviour will be fine to just use the texture index all the time. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add some braces around loops and ifsJason Ekstrand2016-02-091-5/+10
|
* nir: use const_index helpersRob Clark2016-02-0911-24/+23
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* gtn: use const_index helpersRob Clark2016-02-091-8/+9
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: const_index helpersRob Clark2016-02-094-100/+191
| | | | | | | | | | | | | | Direct access to intr->const_index[n], where different slots have different meanings, is somewhat confusing. Instead, let's put some extra info in nir_intrinsic_infos[] about which slots map to what, and add some get/set helpers. The helpers validate that the field being accessed (base/writemask/etc) is applicable for the intrinsic opc, for some extra safety. And nir_print can use this to dump out decoded const_index fields. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Disallow transform feedback varyings with compute shaders.Kenneth Graunke2016-02-091-2/+3
| | | | | | | | | | | | | | If the only stage is MESA_SHADER_COMPUTE, we should complain that there's nothing coming out of the geometry shader stage just as we would if the first stage were MESA_SHADER_FRAGMENT. Also, it's valid for tessellation shaders to be the stage producing transform feedback varyings, so mention those in the compiler error. Found by inspection. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: remove unused nir_variable fieldsTimothy Arceri2016-02-092-20/+0
| | | | | | | These are used in GLSL IR to removed unused varyings and match transform feedback variables. There is no need to use these in NIR. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: remove unrequired forward declarationTimothy Arceri2016-02-091-2/+0
| | | | | | | This was added in 2548092ad80156a4 although I don't see why as it was already in the linker.h header. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: clean up and fix bug in varying linking rulesTimothy Arceri2016-02-091-74/+63
| | | | | | | | | | | | | | | | The existing code was very hard to follow and has been the source of at least 3 bugs in the past year. The existing code also has a bug for SSO where if we have a multi-stage SSO for example a tes -> gs program, if we try to use transform feedback with gs the existing code would look for the transform feedback varyings in the tes stage and fail as it can't find them. V2: Add more code comments, always try to remove unused inputs to the first stage. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: simplify ES Vertex/Fragment shader requirementsTimothy Arceri2016-02-091-28/+28
| | | | | | | | | | | | We really just needed to skip the existing ES < 3.1 check if we have a compute shader, all other scenarios are already covered. * No shaders is a link error. * Geom or Tess without Vertex is a link error which means we always require a Vertex shader and hence a Fragment shader. * Finally a Compute shader linked with any other stage is a link error. Reviewed-by: Kenneth Graunke <[email protected]>