summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: consistently use ifndef guards over pragma onceEmil Velikov2017-03-2231-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 <[email protected]> Acked-by: Vedran Miletić <[email protected]> Acked-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* tests/cache_test: use the blob key's actual first byteGrazvydas Ignotas2017-03-211-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 <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: use a helper to compute cache keysGrazvydas Ignotas2017-03-213-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 <[email protected]> Reviewed-by: Timothy Arceri <[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: Rework conversion opcodesJason Ekstrand2017-03-141-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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: Make image_size a variable-width intrinsicJason Ekstrand2017-03-141-3/+4
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[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]>
* 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-105-5/+5
| | | | | | | | | 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]>
* 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]>
* 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]>
* glsl/nir: Use nir_builder's new control-flow helpersJason Ekstrand2017-03-011-27/+11
| | | | 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]>
* 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-273-15/+14
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use is_image() anywhere it's possibleSamuel Pitoiset2017-02-271-1/+1
| | | | | 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)
* glsl: add has_shader_image_load_store()Samuel Pitoiset2017-02-273-4/+7
| | | | | | | | Preliminary work for ARB_bindless_texture which can interact with ARB_shader_image_load_store. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* compiler: style clean-ups in blob.hTimothy Arceri2017-02-251-21/+21
| | | | Reviewed-by: Elie Tournier <[email protected]>
* glsl: Fix missing-braces warning.Vinson Lee2017-02-241-1/+1
| | | | | | | | | CXX glsl/ast_to_hir.lo glsl/ast_to_hir.cpp: In member function 'virtual ir_rvalue* ast_declarator_list::hir(exec_list*, _mesa_glsl_parse_state*)': glsl/ast_to_hir.cpp:4846:42: warning: missing braces around initializer for 'unsigned int [16]' [-Wmissing-braces] Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: Raise a link error for non-SSO ES programs with a TES but no TCS.Kenneth Graunke2017-02-231-0/+10
| | | | | | | | | | | | | | | OpenGL allows the TCS to be missing and supplies an implicit passthrough shader, but OpenGL ES does not (see section 7.3 of the ES 3.2 spec, cited above in the code). One open question is how to handle this for ARB_ES3_2_compatibility. This patch raises the link error for all ES shading language programs, but it might make sense to base it on the API. The approach taken in this patch is more restrictive, but should still allow any valid ES programs to work in GL. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: enable early_fragment_tests implicitly with post_depth_coverageIago Toral Quiroga2017-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | From ARB_post_depth_coverage: "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. This feature can be enabled with the following layout qualifier in the fragment shader: layout(post_depth_coverage) in; Use of this feature implicitly enables early fragment tests." And a bit later it also adds: "early_fragment_tests" requests that fragment tests be performed before fragment shader execution, as described in section 15.2.4 "Early Fragment Tests" of the OpenGL Specification. If neither this nor post_depth_coverage are declared, per-fragment tests will be performed after fragment shader execution." Fixes: GL45-CTS.post_depth_coverage_tests.PostDepthSampleMask Reviewed-by: Marek Olšák <[email protected]>
* glsl: refactor get_variable_being_redeclared() to return always an ↵Samuel Iglesias Gonsálvez2017-02-231-27/+34
| | | | | | | | | | | | | ir_variable pointer It will return the current variable ('var') or the earlier declaration ('earlier') in case of redeclaration of that variable. In order to distinguish between both, 'is_redeclaration' boolean will indicate in which case we are. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: fix heap-use-after-free in ast_declarator_list::hir()Samuel Iglesias Gonsálvez2017-02-231-2/+4
| | | | | | | | | | | | | | | | | | | | | The get_variable_being_redeclared() function can free 'var' because a re-declaration of an unsized array variable can establish the size, so we set the array type to the 'earlier' declaration and free 'var' as it is not needed anymore. However, the same 'var' is referenced later in ast_declarator_list::hir(). This patch fixes it by picking the ir_variable_mode from the proper ir_variable. This error was detected by Address Sanitizer. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Suggested-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99677 Cc: "17.0" <[email protected]> Cc: "13.0" <[email protected]>
* util/disk_cache: create timestamp and gpu_id dirs when MESA_GLSL_CACHE_DIR ↵Timothy Arceri2017-02-221-0/+40
| | | | | | | | is used The make check test is also updated to make sure these dirs are created. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: resolve extern C workarounds/hacksEmil Velikov2017-02-213-8/+4
| | | | | | | | Do not wrap header inclusion in extern C since it can cause issues. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl/tests: Add UINT64 and INT64 typesRhys Kidd2017-02-211-0/+18
| | | | | | | | | | | | glsl/tests/uniform_initializer_utils.cpp:83:14: warning: enumeration value ‘GLSL_TYPE_UINT64’ not handled in switch [-Wswitch] switch (type->base_type) { ^ glsl/tests/uniform_initializer_utils.cpp:83:14: warning: enumeration value ‘GLSL_TYPE_INT64’ not handled in switch [-Wswitch] Fixes: 8ce53d4a2f3 ("glsl: Add basic ARB_gpu_shader_int64 types") Signed-off-by: Rhys Kidd <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Elie Tournier <[email protected]>
* glsl: link error if unsized array not-last in ssboJose Maria Casanova Crespo2017-02-171-1/+7
| | | | | | | | | | | | | | | | | | | | | | If an unsized declared array is not the last in an SSBO and an implicit size can not be defined on linking time, the linker should raise an error instead of reaching an assertion on GL. This reverts part of commit 3da08e166415a745139c1127040a24e8a45dc553 getting back to the behavior of commit 5b2675093e863a52b610f112884ae12d42513770 The original patch was correct for GLES that should produce a compile-time error but the linker error is still necessary in desktop GL. Fixes the following piglit tests: tests/spec/arb_shader_storage_buffer_object/non_integral_size_array_member.shader_test tests/spec/arb_shader_storage_buffer_object/unsized_array_member.shader_test Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Signed-off-by: Jose Maria Casanova Crespo <[email protected]>
* glsl: fix scons builds with shader cacheTimothy Arceri2017-02-171-0/+2
| | | | | For now its disabled for scons so wrap glsl cache calls in a define conditional.
* nir: Combine the int and double [un]pack opcodesJason Ekstrand2017-02-161-7/+3
| | | | | | | NIR is a typeless IR and the two opcodes, when considered bitwise, do exactly the same thing. There's no reason to have two versions. Reviewed-by: Kenneth Graunke <[email protected]>
* util/disk_cache: allow drivers to pass a directory structureTimothy Arceri2017-02-171-10/+10
| | | | | | | | | | | | | | In order to avoid costly fallback recompiles when cache items are created with an old version of Mesa or for a different gpu on the same system we want to create directories that look like this: ./{TIMESTAMP}_{LLVM_TIMESTAMP}/{GPU_ID} Note: The disk cache util will take a single timestamp string, it is up to the backend to concatenate the llvm string with the mesa string if applicable. Reviewed-by: Nicolai Hähnle <[email protected]>
* st/mesa/glsl: build string of dri options and use as input to building sha ↵Timothy Arceri2017-02-171-0/+6
| | | | | | for shaders Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: reserve parameter storage on cache restoreTimothy Arceri2017-02-171-0/+1
| | | | | | | Since we know how big the list will be we can allocate the storage upfront. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: don't try to load/store buffer object values in the cacheTimothy Arceri2017-02-171-2/+11
| | | | | | Also add an assert to catch buffer overflows. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: don't reprocess or clear UBOs on cache fallbackTimothy Arceri2017-02-171-29/+33
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>