summaryrefslogtreecommitdiff
path: root/src/compiler
AgeCommit message (Collapse)AuthorFilesLines
2017-03-28glsl: fix lower jumps for returns when loop is inside an ifTimothy Arceri1-5/+12
Previously we would just escape the loop and move everything following the loop inside the if to the else branch of a new if with a return flag conditional. However everything outside the if the loop was nested in would still get executed. Adding a new return to the then branch of the new if fixes this and we just let a follow pass clean it up if needed. Fixes: tests/spec/glsl-1.10/execution/vs-nested-return-sibling-loop.shader_test tests/spec/glsl-1.10/execution/vs-nested-return-sibling-loop2.shader_test Cc: "13.0 17.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2017-03-27glsl: Interface Block instances don't need linking validationAndres Gomez1-5/+9
From page 45 (page 52 of the PDF) of the GLSL ES 3.00 v.6 spec: " When instance names are present on matched block names, it is allowed for the instance names to differ; they need not match for the blocks to match. From page 51 (page 57 of the PDF) of the GLSL 4.30 v.8 spec: " When instance names are present on matched block names, it is allowed for the instance names to differ; they need not match for the blocks to match." Therefore, no cross linking validation is needed for the instance name of an Interface Block. This patch will make that no link error will be reported on a program like this: "# VS layout(binding = 1) Block1 { vec4 color; } uni_block; ... # FS layout(binding = 2) Block2 { vec4 color; } uni_block; ..." Fixes GL45-CTS.enhanced_layouts.ssb_layout_qualifier_conflict Signed-off-by: Andres Gomez <agomez@igalia.com> Cc: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-27glsl: UBOs and SSBOs must match the binding qualifier tooAndres Gomez1-0/+3
From page 140 (page 147 of the PDF) of the GLSL ES 3.10 v.4 spec: " 9.2 Matching of Qualifiers The following tables summarize the requirements for matching of qualifiers. It applies whenever there are two or more matching variables in a shader interface. Notes: 1. Yes means the qualifiers must match. ... 9.2.1 Linked Shaders | Qualifier | Qualifier | in/out | Default | uniform | buffer| | Class | | | Uniforms | Block | Block | ... | Layout | binding | N/A | Yes | Yes | Yes |" From page 93 (page 110 of the PDF) of the GL 4.2 (Core Profile) spec: " 2.11.7 Uniform Variables ... Uniform Blocks ... When a named uniform block is declared by multiple shaders in a program, it must be declared identically in each shader. The uniforms within the block must be declared with the same names and types, and in the same order. If a program contains multiple shaders with different declarations for the same named uniform block differs between shader, the program will fail to link." From page 129 (page 150 of the PDF) of the GL 4.3 (Core Profile) spec: " 7.8 Shader Buffer Variables and Shader Storage Blocks ... When a named shader storage block is declared by multiple shaders in a program, it must be declared identically in each shader. The buffer variables within the block must be declared with the same names, types, qualification, and declaration order. If a program contains multiple shaders with different declarations for the same named shader storage block, the program will fail to link." Therefore, if the binding qualifier differs between two linked Uniform or Shader Storage Blocks of the same name, a link error should happen. This patch will make that a link error will be reported on a program like this: "# VS layout(binding = 1) Block { vec4 color; } uni_block1; ... # FS layout(binding = 2) Block { vec4 color; } uni_block2; ..." Signed-off-by: Andres Gomez <agomez@igalia.com> Cc: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-27glsl: on UBO/SSBOs link error reset the number of active blocks to 0Andres Gomez1-0/+6
While it's legal to have an active blocks count > 0 on link failure. Unless we actually assign memory for the blocks array we can end up segfaulting in calls such as glUniformBlockBinding(). To avoid having to NULL check these api calls we simply reset the block count to 0 if the array was not created. Signed-off-by: Andres Gomez <agomez@igalia.com> Cc: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-27glsl, st/shader_cache: check the whole sha1 for zeroGrazvydas Ignotas1-1/+2
The checks were only looking at the first byte, while the intention seems to be to check if the whole sha1 is zero. This prevented all shaders with first byte zero in their sha1 from being saved. This shaves around a second from Deus Ex load time on a hot cache. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-27glsl/shader_cache: restore evicted shader keysGrazvydas Ignotas1-0/+17
Even though the programs themselves stay in cache and are loaded, the shader keys can be evicted separately. If that happens, unnecessary compiles are caused that waste time, and no matter how many times the program is re-run, performance never recovers to the levels of first hot cache run. To deal with this, we need to refresh the shader keys of shaders that were recompiled. An easy way to currently observe this is running Deux Ex, then piglit and Deux Ex again, or deleting just the cache index. The later is causing over a minute of lost time on all later Deux Ex runs, with this patch it returns to normal after 1 run. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-25glsl: Link tests with CLOCK_LIB.Vinson Lee1-3/+6
Fix 'make check' linking errors with glibc < 2.17. CXXLD glsl/glsl_test glsl/.libs/libglsl.a(libmesautil_la-u_queue.o): In function `u_thread_get_time_nano': src/util/../../src/util/u_thread.h:84: undefined reference to `clock_gettime' Signed-off-by: Vinson Lee <vlee@freedesktop.org>
2017-03-25tests/cache_test: mark arguments constGrazvydas Ignotas1-4/+4
While at it, also fix up a failure message to not reference timestamp and gpu dirs as those are no longer being made. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-24nir/lower_wpos_center: support adding sample position to fragment coordinateIago Toral Quiroga2-8/+25
According to section 14.6 of the Vulkan specification: "When sample shading is enabled, the x and y components of FragCoord reflect the location of the sample corresponding to the shader invocation." So add a boolean parameter to the lowering pass to select this behavior when we need it. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-24util/disk_cache: hash pointer size and gpu name into cache keysGrazvydas Ignotas1-11/+2
This allows to get rid of the arch and gpu name directories. v2: (Timothy Arceri) don't use an opaque data type to store pointer size and gpu name. v3: (Timothy Arceri) use blob to store driver keys just make sure to store null terminator for strings, and make sure blob is defined by disk_cache and not it's users. v4: (Timothy Arceri) fix typo, and make ptr_size a uint8_t. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-03-24util/disk_cache: hash timestamps into the cache keysGrazvydas Ignotas1-5/+5
Instead of using a directory, hash the timestamps into the cache keys themselves. Since there is no more timestamp directory, there is no more need for deleting the cache of other mesa versions and we rely on eviction to clean up the old cache entries. This solves the problem of using several incarnations of disk_cache at the same time, where one deletes a directory belonging to the other, like when both OpenGL and gallium nine are used simultaneously (or several different mesa installations). v2: using additional blob instead of trying to clone sha1 state v3: (Timothy Arceri) don't use an opaque data type to store timestamp. V4: (Timothy Arceri) use blob to store driver keys just make sure to store null terminator for strings, and make sure blob is defined by disk_cache and not it's users. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100091
2017-03-23nir: Return progress from nir_convert_from_ssa().Matt Turner2-8/+15
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_io().Matt Turner2-6/+15
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_regs_to_ssa().Matt Turner2-6/+10
And from nir_lower_regs_to_ssa_impl() as well. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_samplers().Matt Turner2-12/+19
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_atomics().Matt Turner2-7/+13
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_clamp_color_outputs().Matt Turner2-10/+22
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_clip_fs().Matt Turner2-3/+7
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_clip_vs().Matt Turner2-5/+7
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_move_vec_src_uses_to_dest().Matt Turner2-6/+18
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_to_source_mods().Matt Turner2-6/+29
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_clip_cull_distance_arrays().Matt Turner2-5/+21
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_var_copies().Matt Turner2-4/+16
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_load_const_to_scalar().Matt Turner2-7/+21
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_64bit_pack().Matt Turner2-4/+14
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_doubles().Matt Turner2-22/+42
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Return progress from nir_lower_vars_to_ssa().Matt Turner2-3/+7
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Fix syntax.Matt Turner2-6/+6
et is not an abbreviation. Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Fix misspellings.Matt Turner4-7/+7
Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-23nir: Stop using apostrophes to pluralize.Matt Turner21-43/+43
Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-22glsl: Link glsl_compiler with CLOCK_LIB.Vinson Lee1-1/+2
Fix linking error on CentOS 6. CXXLD glsl_compiler glsl/.libs/libstandalone.a(lt16-libmesautil_la-u_queue.o): In function `u_thread_get_time_nano': src/util/../../src/util/u_thread.h:84: undefined reference to `clock_gettime' Signed-off-by: Vinson Lee <vlee@freedesktop.org> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-03-22glsl: lower sqrt(abs()) and inversesqrt(abs()) if requestedSamuel Pitoiset2-0/+15
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-22Android: clean-up trailing '\' in make variablesRob Herring2-3/+3
Fixed with the following command: perl -pe 'BEGIN{undef $/;} s/ \\\n\n/\n\n/smg' $(find . -name 'Android.*') Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-03-22spirv: consistently use ifndef guards over pragma onceEmil Velikov3-2/+10
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22nir: consistently use ifndef guards over pragma onceEmil Velikov10-11/+38
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22glsl: consistently use ifndef guards over pragma onceEmil Velikov31-23/+48
Through the glsl headers we had an odd mix of guards be that "ifndef", "pragma once" neither or both. Simplify things by using the more common ones (ifndef) and annotating all the sources, barring the generated builting header - builtin_int64.h. The final header - udivmod64.h - is [seemingly] unused and on its way out (patch purge it is on the mailing list). Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22compiler: consistently use ifndef guards over pragma onceEmil Velikov2-2/+4
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-21nir: Add positional argument specifiers.Vinson Lee2-2/+2
Fix build with Python < 2.7. File "src/compiler/nir/nir_builder_opcodes_h.py", line 46, in <module> from nir_opcodes import opcodes File "src/compiler/nir/nir_opcodes.py", line 178, in <module> unop_convert("{}2{}{}".format(src_t[0], dst_t[0], bit_size), ValueError: zero length field name in format Fixes: 762a6333f21f ("nir: Rework conversion opcodes") Signed-off-by: Vinson Lee <vlee@freedesktop.org>
2017-03-21tests/cache_test: use the blob key's actual first byteGrazvydas Ignotas1-6/+2
There is no need to hardcode it, we can just use blob_key[0]. This is needed because the next patches are going to change how cache keys are computed. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-21util/disk_cache: use a helper to compute cache keysGrazvydas Ignotas3-17/+20
This will allow to hash additional data into the cache keys or even change the hashing algorithm easily, should we decide to do so. v2: don't try to compute key (and crash) if cache is disabled Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-20spirv: Implement IsInf using an integer comparisonJason Ekstrand1-1/+1
Since we already do fabs on the one source, we're guaranteed to get positive infinity if we get any infinity at all. Since +inf only has one IEEE 754 representation, we can use an integer comparison and avoid all of the ordered/unordered issues. Cc: Dave Airlie <airlied@redhat.com> Reviewed-by: Elie Tournier <elie.tournier@collabora.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
2017-03-18glsl: use set for copy propagation killsTimothy Arceri1-37/+28
Previously each time we saw a variable we just created a duplicate entry in the list. This is particularly bad for loops were we add everything twice, and then throw nested loops into the mix and the list was growing expoentially. This stops the glsl-vs-unroll-explosion test which has 16 nested loops from reaching the tests mem usage limit in this pass. The test now hits the mem limit in opt_copy_propagation_elements() instead. I suspect this was also part of the reason this pass can be so slow with some shaders. Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
2017-03-18glsl: don't leak memory when trying to count loop iterationsTimothy Arceri1-2/+3
Suggested-by: Damian Dixon <damian.dixon@gmail.com> Reviewed-by: Elie Tournier <elie.tournier@collabora.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99789
2017-03-15util/sha1: drop _mesa_sha1_{update, format} return typeEmil Velikov2-9/+10
Unused/unchecked by any of the callers. v2: Fix the glsl cases that have crept in since v1 Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Grazvydas Ignotas <notasas@gmail.com>
2017-03-15util/disk_cache: actually enforce cache sizeAlan Swanson1-3/+19
Currently only a one in one out eviction so if at max_size and cache files were to constantly increase in size then so would the cache. Restrict to limit of 8 evictions per new cache entry. V2: (Timothy Arceri) fix make check tests Reviewed-by: Grazvydas Ignotas <notasas@gmail.com>
2017-03-15util/disk_cache: use a thread queue to write to shader cacheTimothy Arceri1-0/+47
This should help reduce any overhead added by the shader cache when programs are not found in the cache. To avoid creating any special function just for the sake of the tests we add a one second delay whenever we call dick_cache_put() to give it time to finish. V2: poll for file when waiting for thread in test V3: fix poll delay to really be 100ms, and simplify the wait function Reviewed-by: Grazvydas Ignotas <notasas@gmail.com>
2017-03-14nir/constant_expressions: Refactor helper functionsJason Ekstrand1-24/+27
Apart from avoiding some unneeded size cases, this shouldn't have any actual functional impact. Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
2017-03-14nir: Rework conversion opcodesJason Ekstrand9-191/+127
The NIR story on conversion opcodes is a mess. We've had way too many of them, naming is inconsistent, and which ones have explicit sizes was sort-of random. This commit re-organizes things and makes them all consistent: - All non-bool conversion opcodes now have the explicit size in the destination and are named <src_type>2<dst_type><size>. - Integer <-> integer conversion opcodes now only come in i2i and u2u forms (i2u and u2i have been removed) since the only difference between the different integer conversions is whether or not they sign-extend when up-converting. - Boolean conversion opcodes all have the explicit size on the bool and are named <src_type>2<dst_type>. Making things consistent also allows nir_type_conversion_op to be moved to nir_opcodes.c and auto-generated using mako. This will make adding int8, int16, and float16 versions much easier when the time comes. Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-14glsl/nir: Use nir_type_conversion_opJason Ekstrand1-37/+32
Using the helper is way better than hand-coding the universe. Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-14nir: Rewrite nir_type_conversion_opJason Ekstrand1-63/+92
The original version was very convoluted and tried way too hard to not just have the nested switch statement that it needs. Let's just write the obvious code and then we know it's correct. This fixes a bunch of missing cases particularly with int64. Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>