summaryrefslogtreecommitdiff
path: root/src/compiler
AgeCommit message (Collapse)AuthorFilesLines
2016-12-19nir/docs: use syntax highlighted code blocksDylan Baker4-14/+14
2016-12-19docs: Add nir documentationDylan Baker6-0/+992
2016-12-16spirv/nir: add support for ImageGatherExtendedIlia Mirkin1-7/+69
The strategy is to do the same thing that the GLSL lower_offset_arrays pass does - create 4 separate texture gather ops, one per offset, and read in the results from each gather's w component to recreate the desired result. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-12-16nir: Remove nir_array from lower_locals_to_regsThomas Helland1-9/+0
We do nothing but initialize it, add to it, and delete it. This is a fallout from removing constant initializer support. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-12-16nir: Turn imov/fmov of undef into undefTimothy Arceri1-6/+6
Reverting the previous attempt at this a5502a721fd30fd resulted in the following Vulkan test failing. dEQP-VK.glsl.return.return_in_dynamic_loop_dynamic_vertex This time we use the num_components from the alu dest rather than num_inputs to the op to determine the size of the undef. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Cc: "13.0" <mesa-stable@lists.freedesktop.org> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99100
2016-12-15nir/lower_tex: fix number of components in replace_gradient_with_lod()Iago Toral Quiroga1-1/+2
We should make the dest in the textureLod() operation have the same number of components as the destination in the original textureGrad() Fixes regression in ES3-CTS.gtf.GL3Tests.shadow Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99072 Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-12-15Revert "nir: Turn imov/fmov of undef into undef."Timothy Arceri1-3/+1
This reverts commit 6aa730000fea84a14b49828a4bb30761d43903bf. This was changing the size of the undef to always be 1 (the number of inputs to imov and fmov) which is wrong, we could be moving a vec4 for example. Acked-by: Kenneth Graunke <kenneth@whitecape.org> Cc: "13.0" <mesa-stable@lists.freedesktop.org>
2016-12-13nir/lower_tex: lower gradients on shadow cube maps if lower_txd_shadow is setIago Toral Quiroga1-2/+4
Even if lower_txd_cube_map isn't. Suggested by Ken to make the flag more consistent with its name. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-12-13nir/lower_tex: add lowering for texture gradient on shadow samplersIago Toral Quiroga2-0/+67
This is ported from the Intel lowering pass that we use with GLSL IR. This takes care of lowering texture gradients on shadow samplers other than cube maps. Intel hardware requires this for gen < 8. v2 (Ken): - Use the helper function to retrieve ddx/ddy - Swizzle away size components we are not interested in v3: - Get rid of the ddx/ddy helper and use nir_tex_instr_src_index instead (Ken, Eric) v4: - Add a 'continue' statement if the lowering makes progress because it replaces the original texture instruction Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v3)
2016-12-13nir/lower_tex: add lowering for texture gradient on cube mapsIago Toral Quiroga2-0/+213
This is ported from the Intel lowering pass that we use with GLSL IR. The NIR pass only handles cube maps, not shadow samplers, which are also lowered for gen < 8 on Intel hardware. We will add support for that in a later patch, at which point we should be able to remove the GLSL IR lowering pass. v2: - added a helper to retrieve ddx/ddy parameters (Ken) - No need to make size.z=1.0, we are only using component x anyway (Iago) v3: - Get rid of the ddx/ddy helper and use nir_tex_instr_src_index instead (Ken, Eric) v4: - When emitting the textureLod operation, copy all texture parameters from the original textureGrad() (except for ddx/ddy) using a loop - Add a 'continue' statement if the lowering makes progress because it replaces the original texture instruction Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v3)
2016-12-13nir/lower_tex: generalize get_texture_size()Iago Toral Quiroga1-5/+10
This was written specifically for RECT samplers. Make it more generic so we can call this from the gradient lowerings too. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-12-12treewide: s/comparitor/comparator/Ilia Mirkin16-37/+37
git grep -l comparitor | xargs sed -i 's/comparitor/comparator/g' Just happened to notice this in a patch that was sent and included one of the tokens in question. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-12-12nir: Only float and double types can be matricesIan Romanick2-19/+24
In 19a541f (nir: Get rid of nir_constant_data) a number of places that operated on nir_constant::values were mechanically converted to operate on the whole array without regard for the base type. Only GLSL_TYPE_FLOAT and GLSL_TYPE_DOUBLE can be matrices, so only those types can have data in the non-0 array element. See also b870394. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com> Cc: Iago Toral Quiroga <itoral@igalia.com>
2016-12-12nir: Move fsat outside of fmin/fmax if second arg is 0 to 1.Matt Turner2-0/+25
instructions in affected programs: 550 -> 544 (-1.09%) helped: 6 cycles in affected programs: 6952 -> 6850 (-1.47%) helped: 6 Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-12-12glsl: remember per-component vertex streams for packed varyingsNicolai Hähnle3-2/+24
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2016-12-09spirv: Use a simpler and more correct implementaiton of tanh()Jason Ekstrand1-9/+14
The new implementation is more correct because it clamps the incoming value to 10 to avoid floating-point overflow. It also uses a much reduced version of the formula which only requires 1 exp() rather than 2. This fixes all of the dEQP-VK.glsl.builtin.precision.tanh.* tests. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Cc: "13.0" <mesa-dev@lists.freedesktop.org>
2016-12-09glsl: Use a simpler formula for tanhJason Ekstrand1-8/+10
The formula we have used in the past is a trivial reduction from the definition by simply multiplying both the numerator and denominator of the formula by 2. However, multiplying by e^x, you can further reduce it. This allows us to get rid of one side of the clamp and two of exponential functions which should make it faster. The new formula still passes the dEQP precision tests for tanh so it should be fine. Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-12-09compiler/glsl: fix precision problem of tanhHaixia Shi1-2/+10
Clamp input scalar value to range [-10, +10] to avoid precision problems when the absolute value of input is too large. Fixes dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.* test failures. v2: added more explanation in the comment. v3: fixed a typo in the comment. Signed-off-by: Haixia Shi <hshi@chromium.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Cc: "13.0" <mesa-dev@lists.freedesktop.org>
2016-12-07mesa: add support for GL_INTEL_conservative_rasterizationLionel Landwerlin8-7/+70
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Chris Forbes <chrisforbes@google.com>
2016-12-07mesa: Add GL and GLSL plumbing for ARB_post_depth_coverage for i965 (gen9+).Plamena Manolova8-1/+49
This extension allows the fragment shader to control whether values in gl_SampleMaskIn[] reflect the coverage after application of the early depth and stencil tests. Signed-off-by: Plamena Manolova <plamena.manolova@intel.com> Reviewed-by: Chris Forbes <chrisforbes@google.com>
2016-12-06nir: In split_var_copies_block, uint, int, and bool types cannot be matricesIan Romanick1-3/+5
Noticed while adding support for 64-bit integer types. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-12-06glsl: (trivial) fix type typoRoland Scheidegger1-1/+1
Accidentally changed the type of a constant in df33f11b39abf313a0db7b9fefaf739b88133161 causing assertion failures.
2016-12-06glsl: fix ldexp lowering if bitfield insert lowering is also requestedRoland Scheidegger1-5/+16
Trivial, this just resurrects the code which was there once upon a time (the code can't lower instructions generated in the lowering pass there, and even if it could it would probably be suboptimal). This fixes piglit mesa_shader_integer_functions fs-ldexp.shader_test and vs-ldexp.shader_test with llvmpipe. Reviewed-by: Matt Turner <mattst88@gmail.com>
2016-12-05nir: Remove some unused fields from nir_variableJason Ekstrand3-43/+0
All of these are happily set from glsl_to_nir or spirv_to_nir but their values are never used for anything. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-05nir: Delete most of the constant_initializer supportJason Ekstrand5-146/+12
Constant initializers have been a constant (ha!) pain for quite some time. While they're useful from a language perspective, people writing passes or backends really don't want deal with them most of the time. This commit removes most of the constant initializer support from NIR. It is expected that you call nir_lower_constant_initializers VERY EARLY to ensure that they're gone before you do anything interesting. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-05nir: Simplify nir_lower_gs_intrinsicsJason Ekstrand1-21/+16
It's only ever called on single-function shaders. At this point, there are a lot of helpers that can make it all much simpler. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-05nir/lower_returns: Stop using constant initializersJason Ekstrand1-4/+5
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-05glsl/nir: Call nir_lower_constant_initializersJason Ekstrand1-0/+2
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-05nir: Add a pass for lowering away constant initializersJason Ekstrand3-0/+115
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-03spirv: Builtin Layer is an input for fragment shadersIago Toral Quiroga1-1/+6
This change makes it so we emit a load_input intrinsic when Layer is read in a fragment shader. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-12-02nir: Get rid of nir_constant_dataJason Ekstrand7-105/+98
This has bothered me for about as long as NIR has been around. Why do we have two different unions for constants? No good reason other than one of them is a direct port from GLSL IR. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-12-02st/mesa/glsl: move Version to gl_shader_program_dataTimothy Arceri3-18/+23
This is mostly just used during linking however the st uses it when updating textures. In order to store gl_program in the CurrentProgram array rather than gl_shader_program we need to move this field to the shared gl_shader_program_data struct. Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-30glsl: use linked_shaders bitmask to iterate stages for subroutine fieldsTimothy Arceri2-31/+26
This should be faster than looping over every stage and null checking, but will also make the code a bit cleaner when we switch to getting more fields from gl_program rather than from gl_linked_shader as we can just copy the pointer and not need to worry about null checking then copying. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2016-11-30mesa/glsl: add bitmask to track stages a program was linked againstTimothy Arceri1-0/+1
This will be used to enable us to store the current gl_program rather than gl_shader_program in the gl_pipline_object allowing us to simplify handing of validation. Also we should not be depending on _LinkedShader for this information as it may contain shaders from a failed linking attempt rather than the current program still in use. We could also use this mask to iterate over the stages during linking with _mesa_bit_scan() rather then the current method of NULL checking each stage. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2016-11-29nir: print var binding in dumps.Dave Airlie1-1/+1
This only useful for spir-v shaders, but I keep finding myself having to add it. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
2016-11-29mesa: fix active subroutine uniforms properlyTimothy Arceri2-1/+2
07fe2d565b introduced a big hack in order to return NumSubroutineUniforms when querying ACTIVE_RESOURCES for <shader>_SUBROUTINE_UNIFORM interfaces. However this is the wrong fix we are meant to be returning the number of active resources i.e. the count of subroutine uniforms in the resource list which is what the code was previously doing, anything else will cause trouble when trying to retrieve the resource properties based on the ACTIVE_RESOURCES count. The real problem is that NumSubroutineUniforms was counting array elements as separate uniforms but the innermost array is always considered a single uniform so we fix that count instead which was counted incorrectly in 7fa0250f9. Idealy we could probably completely remove NumSubroutineUniforms and just compute its value when needed from the resource list but this works for now. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Cc: 13.0 <mesa-stable@lists.freedesktop.org>
2016-11-25Revert "glsl: allow layout qualifier overrides with ↵Andres Gomez1-6/+1
ARB_shading_language_420pack" This reverts commit aaa69c79cd584db4d9c6ea7794e93d29f3d54572. The commit was erroneous because the ast_layout_expression class is meant to hold a list used for an after check that all the declared values for a layout-qualifier-name are consistent. Therefore, the check for the possibility of duplicated values was previously fixed to happen much sooner, in the GLSL parser and the merge of layout qualifiers, and the process_qualifier_constant method only needs to check that the values are consistent. By now, those layout-qualifier-name represented as a ast_layout_expression are "max_vertices", "invocations", "vertices", "local_size_[x|y|z]" and "xfb_stride". From page 40 (page 46 of the PDF) of the GLSL 1.50 spec: " All geometry shader output layout declarations in a program must declare the same layout and same value for max_vertices." From page 44 (page 50 of the PDF) of the GLSL 4.00 spec: " If an invocation count is declared, all such declarations must specify the same count." From page 47 (page 53 of the PDF) of the GLSL 4.00 spec: " All tessellation control shader layout declarations in a program must specify the same output patch vertex count." From page 60 (page 66 of the PDF) of the GLSL 4.30 spec: " Also, if such a layout qualifier is declared more than once in the same shader, all those declarations must set the same set of local work-group sizes and set them to the same values; otherwise a compile-time error results. If multiple compute shaders attached to a single program object declare local work-group size, the declarations must be identical; otherwise a link-time error results." From page 73 (page 79 of the PDF) of the GLSL 4.40 spec: " While xfb_stride can be declared multiple times for the same buffer, it is a compile-time or link-time error to have different values specified for the stride for the same buffer." Fixes GL44-CTS.enhanced_layouts.xfb_duplicated_stride Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25Revert "glsl: geom shader max_vertices layout must match."Andres Gomez3-13/+9
This reverts commit 4c863993780a11cea6f88fa0682796bee5794042. The commit was erroneous because the ast_layout_expression class was created to hold a list of values for a layout-qualifier-name which is allowed to appear in more than one expression in the same shader/program but not to hold different values. In other words, the list is used for an after check that all the declared values for a layout-qualifier-name are consistent. Therefore, the values stored must match always, not just for "max_vertices" or any other eventual layout-qualifier-name. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: push layout-qualifier-name values from variable declarations to globalAndres Gomez3-23/+60
After the previous modifications in the merging of the layout-qualifier-name values, we no longer push the final value in a declaration to the global values. This regression happens because we don't call for merging on the right-most layout qualifier of a declaration which is also the overriding one in case of multiple appearances. Now, we add a new method to push these values to the global ones and we call for this just after all the layout-qualifier collapsing has happened in a declaration. This simplifies how this was working in two ways; we make a clear differentiation of when we are pushing this to the global values since before it was mixed in the merging call and we only run this once all the processing for layout-qualifiers in a declaration has happened. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: simplified error checking for duplicated layout-qualifiersAndres Gomez2-24/+6
The GLSL parser has been simplified to check for the needed GL_ARB_shading_language_420pack extension just when merging the qualifiers in the proper cases. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: simplified ast_type_qualifier::merge_into_[in|out]_qualifier APIAndres Gomez3-12/+10
Since we modified the way in which multiple repetitions of the same layout-qualifier-name in a single declaration collapse into the ast_type_qualifier class, we can simplify the merge_into_[in|out]_qualifier APIs through removing the create_node parameter. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: ignore all but the rightmost layout qualifier name from the rightmost ↵Andres Gomez3-77/+84
layout qualifier From page 46 (page 52 of the PDF) of the GLSL 4.20 spec: " More than one layout qualifier may appear in a single declaration. If the same layout-qualifier-name occurs in multiple layout qualifiers for the same declaration, the last one overrides the former ones." Consider this example: " #version 150 #extension GL_ARB_shading_language_420pack: enable layout(max_vertices=2) layout(max_vertices=3) out; layout(max_vertices=3) out;" Although different values for "max_vertices" results in a compilation error. The above code is valid because max_vertices=2 is ignored. Hence, when merging qualifiers in an ast_type_qualifier, we now ignore new appearances of a same layout-qualifier-name if the new "is_multiple_layouts_merge" parameter is on, since the GLSL parser works in this case from right to left. In addition, any special treatment for the buffer, uniform, in or out layout defaults has been moved in the GLSL parser to the rule triggered just after any previous processing/merging on the layout-qualifiers has happened in a single declaration since it was run too soon previously. Fixes GL44-CTS.shading_language_420pack.qualifier_override_layout Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: refactor duplicated validations between 2 layout-qualifiersAndres Gomez1-50/+76
Several layout-qualifier validations are duplicated in the merge_qualifier and validate_in_qualifier methods. We would rather have them refactored into single calls. Suggested by Timothy. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: assert on incoherent point mode layout-id-qualifier validationAndres Gomez1-10/+6
The point mode value in an ast_type_qualifier can only be true if the flag is already set since this layout-id-qualifier can only be or not be present in a shader. Hence, it is useless to check for its value if the flag is already set. Just replaced with an assert. V2: assert instead of checking for coherence and raising a compilation error. Suggested by Timothy. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: remove unneeded check for incompatible primitive types in GSAndres Gomez1-10/+3
The validation of the default in layout qualifier already assures that we won't have 2 ast_gs_input_layout objects with different primitive type values. In fact, the validation already assures that we won't have 2 ast_gs_input_layout objects in the AST tree at all. The check for an error in the shader has been replaced by an assert. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: simplifies the merge of the default in layout qualifierAndres Gomez1-84/+81
The merge into the default in layout qualifier duplicates a lot of code that can be reused from the generic merge method. Now, we use the generic merge method inside the specific merge for the default in layout qualifier. The generic merge method has been completed with some bits that were only present in the merge for the default in layout qualifier and the specific validation bits have been moved to the validation method for the default in layout qualifier. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: split default in layout qualifier mergeAndres Gomez3-62/+93
Currently, the default in layout qualifier merge performs specific validation and merge. We want to split out the validation from the merge so they can be done independently. Additionally, for simplification, the direction of the validation and merge is changed so the ast_type_qualifier calling the method is the one validated and merged against the default in qualifier. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: split default out layout qualifier mergeAndres Gomez3-37/+72
Currently, the default out layout qualifier merge performs specific validation and merge. We want to split out the validation from the merge so they can be done independently. Additionally, for simplification, the direction of the validation and merge is changed so the ast_type_qualifier calling the method is the one validated and merged against the default out qualifier. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: merge layouts into the default one as the last step in interface blocksAndres Gomez4-22/+40
Consider this example: " #version 150 core #extension GL_ARB_shading_language_420pack: require #extension GL_ARB_explicit_attrib_location: require layout(location=0) out vec4 o; layout(binding=2) layout(binding=3, std140) uniform U { vec4 a; } u[2];" As there is 2 layout-qualifiers for the uniform U and the binding layout-qualifier-id is duplicated, the rules set by the ARB_shading_language_420pack spec state that the rightmost should prevail. Our ast_type_qualifier merges with others in a way that if the value for a layout-qualifier-id is set in both, the object being merged overwrites the value of the object invoking the merge. Hence, the merge has to happen from the left layout towards the right one and this was not happening for interface blocks because we were merging into the default layout qualifier. Now, the merge is done from left to right and, as a last step, we merge into the default layout qualifier if needed, so the values of the explicit layouts prevail over it. V2: added a default_layout variable instead of a layout_helper and make the merge directly over the layout one. Suggested by Timothy. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>
2016-11-25glsl: ignore all but the rightmost layout-qualifier-nameAndres Gomez1-5/+6
When a layout contains a duplicated layout-qualifier-name in a single declaration, only the last occurrence should be taken into account. From page 59 (page 65 of the PDF) of the GLSL 4.40 spec: " More than one layout qualifier may appear in a single declaration. Additionally, the same layout-qualifier-name can occur multiple times within a layout qualifier or across multiple layout qualifiers in the same declaration. When the same layout-qualifier-name occurs multiple times, in a single declaration, the last occurrence overrides the former occurrence(s)." Consider this example: " #version 150 #extension GL_ARB_enhanced_layouts: enable layout(max_vertices=2, max_vertices=3) out; layout(max_vertices=3) out;" Although different values for "max_vertices" results in a compilation error. The above code is valid because max_vertices=2 is ignored. When merging qualifiers in an ast_type_qualifier, we now simply ignore new appearances of a same layout-qualifier-name if the "is_single_layout_merge" parameter is true, this works because the GLSL parser processes qualifiers from right to left. Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Signed-off-by: Andres Gomez <agomez@igalia.com>