summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* spirv: Implement IsInf using an integer comparisonJason Ekstrand2017-03-201-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 <[email protected]> Reviewed-by: Elie Tournier <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: use set for copy propagation killsTimothy Arceri2017-03-181-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 <[email protected]>
* glsl: don't leak memory when trying to count loop iterationsTimothy Arceri2017-03-181-2/+3
| | | | | | Suggested-by: Damian Dixon <[email protected]> Reviewed-by: Elie Tournier <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99789
* util/sha1: drop _mesa_sha1_{update, format} return typeEmil Velikov2017-03-152-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 <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: actually enforce cache sizeAlan Swanson2017-03-151-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 <[email protected]>
* util/disk_cache: use a thread queue to write to shader cacheTimothy Arceri2017-03-151-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 <[email protected]>
* nir/constant_expressions: Refactor helper functionsJason Ekstrand2017-03-141-24/+27
| | | | | | | | Apart from avoiding some unneeded size cases, this shouldn't have any actual functional impact. Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* nir: Rework conversion opcodesJason Ekstrand2017-03-149-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 <[email protected]>
* glsl/nir: Use nir_type_conversion_opJason Ekstrand2017-03-141-37/+32
| | | | | | Using the helper is way better than hand-coding the universe. Reviewed-by: Eric Anholt <[email protected]>
* nir: Rewrite nir_type_conversion_opJason Ekstrand2017-03-141-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 <[email protected]>
* nir: Add a get_nir_type_for_glsl_base_type helperJason Ekstrand2017-03-141-2/+8
| | | | Reviewed-by: Eric Anholt <[email protected]>
* nir/validate: Rework ALU bit-size rule validationJason Ekstrand2017-03-141-32/+33
| | | | | | | | | | | The original bit-size validation wasn't capable of properly dealing with instructions with variable bit sizes. An attempt was made to handle it by looking at source and destinations but, because the validation was done in validate_alu_(src|dest), it didn't really have the needed information. The new validation code is much more straightforward and should be more correct. Reviewed-by: Eric Anholt <[email protected]>
* nir/validate: Validate that bit sizes and components always matchJason Ekstrand2017-03-141-38/+63
| | | | | | | | | | | | | We've always required bit sizes to match but the rules for number of components have been a bit loose. You've never been allowed to source from something with less components than you consume, but more has always been fine. This changes the validator to require that they match exactly. The fact that they don't always match has been a source of confusion in NIR for quite some time and it's time we got rid of it. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: Make image_size a variable-width intrinsicJason Ekstrand2017-03-143-11/+16
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/lower_tex: Use tex_instr_dest_size for txs destinationsJason Ekstrand2017-03-141-1/+2
| | | | | | | | | Using coord_components of the source texture is correct for everything except cube maps where it's off by one. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Restrict the number of channels in texture coordinatesJason Ekstrand2017-03-141-1/+2
| | | | | | | | | Some SPIR-V texturing instructions pack more than the texture coordinate into the coordinate source. We need to mask off the unused channels. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/copy_prop: Respect the source's number of componentsJason Ekstrand2017-03-141-33/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the near future we are going to require that the num_components in a src dereference match the num_components of the SSA value being dereferenced. To do that, we need copy_prop to not remove our MOVs from a larger SSA value into an instruction that uses fewer channels. Because we suddenly have to know how many components each source has, this makes the pass a bit more complicated. Fortunately, copy propagation is the only pass that cares about the number of components are read by any given source so it's fairly contained. Shader-db results on Sky Lake: total instructions in shared programs: 13318947 -> 13320265 (0.01%) instructions in affected programs: 260633 -> 261951 (0.51%) helped: 324 HURT: 1027 Looking through the hurt programs, about a dozen are hurt by 3 instructions and the rest are all hurt by 2 instructions. From a spot-check of the shaders, the story is always the same: They get a vec4 from somewhere (frequently an input) and use the first two or three components as a texture coordinate. Because of the vector component mismatch, we have a mov or, more likely, a vecN sitting between the texture instruction and the input. This means that the back-end inserts a bunch of MOVs and split_virtual_grfs() goes to town. Because the texture coordinate is also used by some other calculation, register coalesce can't combine them back together and we end up with an extra 2 MOV instructions in our shader. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/intrinsics: Make load_barycentric_input take a 2-component coorJason Ekstrand2017-03-141-1/+3
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Cc: "17.0 13.0" <[email protected]>
* glsl: don't use ralloc for blob creationTimothy Arceri2017-03-134-20/+15
| | | | | | There is no need to use ralloc here. Reviewed-by: Marek Olšák <[email protected]>
* glsl: don't recompile a shader on fallback unless neededTimothy Arceri2017-03-121-0/+7
| | | | | | | | | | | | | | | | | | | | | Because we optimistically skip compiling shaders if we have seen them before we may need to compile them later at link time if they haven't yet been use in a specific combination to create a program. Rather than always recompiling we take advantage of the gl_compile_status enum introduced in the previous patch to only compile when we have previously skipped compilation. This helps with regressions in app start-up times on cold cache runs, compared with no cache. Deus Ex: Mankind Divided start-up times: cache disabled: ~3m15s cold cache master: ~4m23s cold cache with this patch: ~3m33s Acked-by: Marek Olšák <[email protected]>
* mesa/glsl: introduce new gl_compile_status enumTimothy Arceri2017-03-121-2/+2
| | | | | | | This will allow us to tell if a shader really has been compiled or if the shader cache has just seen it before. Acked-by: Marek Olšák <[email protected]>
* glsl/tests: remove any bashismsEmil Velikov2017-03-102-4/+4
| | | | | | Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Andreas Boll <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* nir: remove shebang from python scriptsEmil Velikov2017-03-107-7/+0
| | | | | | | Analogous to earlier commit(s). Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl: remove shebang from python scriptsEmil Velikov2017-03-102-2/+0
| | | | | | | | All of the scripts are [must be] executed via $PYTHON2 [or equivalent] hence why they are missing the execute bit. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl/tests: remove execute bit from compare_ir python scriptEmil Velikov2017-03-101-0/+0
| | | | | | | | | Nearly all the python scripts used in-tree are invoked via $PYTHON2 or equivalent. As such having the execute bit not needed and generally ill-advised. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl/tests: suffix .sh/.py files as applicableEmil Velikov2017-03-106-9/+9
| | | | | | | | | This makes it easier/clearer as to: - if the file should have the execute bit set (.py should not) - do we need the shebang in the first place and if so what it should be Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* exec_list: Add a foreach_list_typed_from macroRobert Bragg2017-03-091-0/+5
| | | | | | | | | This allows iterating list nodes from a given start point instead of necessarily the list head. Signed-off-by: Robert Bragg <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
* glsl/blob: clear padding bytesGrazvydas Ignotas2017-03-091-3/+6
| | | | | | | | | | Since blob is intended for serializing data, it's not a good idea to leave padding holes with uninitialized data, which may leak heap contents and hurt compression if the blob is later compressed, like done by shader cache. Clear it. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: builtin: always return clones of the builtinsLionel Landwerlin2017-03-093-8/+20
| | | | | | | | | | | | | | | | | | | | | | Builtins are created once and allocated using their own private ralloc context. When reparenting IR that includes builtins, we might be steal bits of builtins. This is problematic because these builtins might now be freed when the shader that includes then last is disposed. This might also lead to inconsistent ralloc trees/lists if shaders are created on multiple threads. Rather than including builtins directly into a shader's IR, we should include clones of them in the ralloc context of the shader that requires them. This fixes double free issues we've been seeing when running shader-db on a big multicore (72 threads) server. v2: Also rename _mesa_glsl_find_builtin_function_by_name() to better reflect how this function is used. (Ken) v3: Rename ctx to mem_ctx (Ken) Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* spirv: Silence unused variable warnings in release modeJason Ekstrand2017-03-071-0/+1
| | | | Reviewed-by: Jordan Justen <[email protected]>
* util/disk_cache: fix make checkTimothy Arceri2017-03-061-7/+12
| | | | | Fixes make check after 11f0efec2e615f5233d which caused disk cache to create an additional directory.
* Revert "glsl: Switch to disable-by-default for the GLSL shader cache"Timothy Arceri2017-03-061-5/+0
| | | | | | | | | This reverts commit 0f60c6616e93cba72bff4fbfedb72a753ef78e05. Piglit and all games tested so far seem to be working without issue. This change will allow wide user testing and we can decided before the next release if we need to turn it off again. Reviewed-by: Marek Olšák <[email protected]>
* nir/int64: Properly handle imod/iremJason Ekstrand2017-03-031-3/+21
| | | | | | | | | | | The previous implementation was fine for GLSL which doesn't really have a signed modulus/remainder. They just leave the behavior undefined whenever either source is negative. However, in SPIR-V, there is a defined behavior for negative arguments. This commit beefs up the pass so that it handles both correctly. Tested using a hacked up version of the Vulkan CTS test to get 64-bit support. Reviewed-by: Matt Turner <[email protected]>
* nir/builder: Add an int64 immediate helperJason Ekstrand2017-03-031-0/+11
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: fix subroutine mismatch between declarations/definitionsSamuel Pitoiset2017-03-035-8/+18
| | | | | | | | | | | | | | | | | | | | | Previously, when q.subroutine was set to 1, a new subroutine declaration was added to the AST, while 0 meant a subroutine definition has been detected by the parser. Thus, setting the q.subroutine flag in both situations is obviously wrong because a new type identifier is added instead of trying to match the declaration. To fix it up, introduce ast_type_qualifier::is_subroutine_decl() to differentiate declarations and definitions easily. This fixes a regression with: arb_shader_subroutine/compiler/direct-call.vert Cc: Mark Janes <[email protected]> Fixes: be8aa76afd ("glsl: remove unecessary flags.q.subroutine_def") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100026 Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* i965: Do int64 lowering in NIRJason Ekstrand2017-03-011-54/+53
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Add a simple int64 lowering passJason Ekstrand2017-03-013-0/+289
| | | | | | | | | | | | | | | | | | The algorithms used by this pass, especially for division, are heavily based on the work Ian Romanick did for the similar int64 lowering pass in the GLSL compiler. v2: Properly handle vectors v3: Get rid of log2_denom stuff. Since we're using bcsel, we do all the calculations anyway and this is just extra instructions. v4: - Add back in the log2_denom stuff since it's needed for ensuring that the shifts don't overflow. - Rework the looping part of the pass to be easier to expand. Reviewed-by: Matt Turner <[email protected]>
* spirv: Use nir_builder for control flowJason Ekstrand2017-03-011-31/+14
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/lower_indirect: Use nir_builder control-flow helpersJason Ekstrand2017-03-011-30/+5
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/lower_gs_intrinsics: Use nir_builder control-flow helpersJason Ekstrand2017-03-011-6/+3
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl/nir: Use nir_builder's new control-flow helpersJason Ekstrand2017-03-011-27/+11
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/builder: Add support for easily building control-flowJason Ekstrand2017-03-011-0/+95
| | | | | | | | | | | Each of the pop functions (and push_else) take a control flow parameter as their second argument. If NULL, it assumes that the builder is in a block that's a direct child of the control-flow node you want to pop off the virtual stack. This is what 90% of consumers will want. The SPIR-V pass, however, is a bit more "creative" about how it walks the CFG and it needs to be able to pop multiple levels at a time, hence the argument. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl/int64: Fix a typo in imod64Jason Ekstrand2017-03-012-15/+9
| | | | | | | The zy swizzle gives us one component of quotient and one component of remainder. What we wanted was zw for the remainder. Reviewed-by: Matt Turner <[email protected]>
* glsl: remove unecessary flags.q.subroutine_defSamuel Pitoiset2017-03-015-10/+7
| | | | | | | | | | | | | | | This bit is definitely not necessary because subroutine_list can be used instead. This frees one more bit in the flags.q struct which is nice because arb_bindless_texture will need 4 bits for the new layout qualifiers. No piglit regressions found (including compiler tests) with "-t subroutine". v2: set the subroutine flag for validating illegal flags Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* compiler: Free types in _mesa_glsl_release_types() rather than autofree.Kenneth Graunke2017-02-271-1/+4
| | | | | | | | | | | | | | | | | Instead of using ralloc_autofree_context() to install an atexit() handler to ralloc_free(glsl_type::mem_ctx), we can simply free them from _mesa_glsl_release_types(). This is effectively the same, because _mesa_glsl_release_types() is called from _mesa_destroy_shader_compiler(), which is called from Mesa's one_time_fini() function, which Mesa installs as an atexit() handler. The one advantage here is that it ensures the built-in functions are destroyed before the types. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl: reject samplers not declared as uniform/function params earlierSamuel Pitoiset2017-02-271-0/+9
| | | | | | | | | | | | | | This improves consistency with image variables and atomic counters which are already rejected the same way. Note that opaque variables can't be treated as l-values, which means only the 'in' function parameter is allowed. v2: rewrite commit message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> (v1) Reviewed-by: Marek Olšák <[email protected]> (v2)
* glsl: use is_sampler() anywhere it's possibleSamuel Pitoiset2017-02-274-16/+15
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use is_image() anywhere it's possibleSamuel Pitoiset2017-02-272-3/+2
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add missing blend_support qualifier in validate_flags()Samuel Pitoiset2017-02-271-1/+2
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: use an enum for AMD_conservative_depth layout qualifiersSamuel Pitoiset2017-02-274-35/+40
| | | | | | | | | | | | | | | | | | | | | | | The main idea behind this is to free some bits in the flags.q struct because currently all 64-bits are used and we can't add more layout qualifiers without reaching a static assert. In order to do that (mainly for ARB_bindless_texture), use an enumeration for the AMD_conservative_depth layout qualifiers because it's forbidden to declare more than one depth qualifier for gl_FragDepth. Note that ast_type_qualifier::merge_qualifier() will prevent using duplicate layout qualifiers by returning a compile-time error. No piglit regressions found (including compiler tests) with RX480 on RadeonSI. v2: use a switch case Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]> (v1)