summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* nir/spirv: handle if's with same label in both branchesJuan A. Suarez Romero2017-09-121-2/+10
| | | | | | | | | | | | | | When a conditional branch has the same labels in the "if" part and in the "else" part, then we have the same cfg block, and it must be handled once. v2: handle it the same way as OpBranch (Jason). Fixes: dEQP-VK.spirv_assembly.instruction.compute.conditional_branch.same_labels* dEQP-VK.spirv_assembly.instruction.graphics.conditional_branch.same_labels* Reviewed-by: Jason Ekstrand <[email protected]>
* nir/spirv: fix chain access with different index bit sizesSamuel Iglesias Gonsálvez2017-09-111-3/+8
| | | | | | | | | | | | Currently we support 32-bit indexes/offsets all over the driver, so we convert them to that bit size. Fixes dEQP-VK.spirv_assembly.instruction.*.indexing.* v2: Use u2u32 instead (Jason). Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: put compact into bitfields in nir_variable_dataDave Airlie2017-09-071-1/+1
| | | | | | | | | | This being declared bool means it won't get merged with the previous bitfields, this seems like an oversight rather than deliberate. Noticed when running pahole. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* spirv: Add support for the HelperInvocation builtinJason Ekstrand2017-09-051-1/+4
| | | | | | | | I have no idea how this got missed but it's been missing since forever. Cc: [email protected] Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: define YY_NO_INPUT to prevent unused symbol warningsMatt Turner2017-08-291-0/+1
| | | | | | | | | | | | Otherwise clang warns: glsl/glsl_lexer.cpp:3507:16: warning: function 'yyinput' is not needed and will not be emitted [-Wunneeded-internal-declaration] static int yyinput (yyscan_t yyscanner) ^ Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* nir: Remove series of unnecessary conversionsMatt Turner2017-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | Clang warns: warning: absolute value function 'fabsf' given an argument of type 'const float64_t' (aka 'const double') but has parameter of type 'float' which may cause truncation of value [-Wabsolute-value] float64_t dst = bit_size == 64 ? fabs(src0) : fabsf(src0); The type of the ternary expression will be the common type of fabs() and fabsf(): double. So fabsf(src0) will be implicitly converted to double. We may as well just convert src0 to double before a call to fabs() and remove the needless complexity, à la float64_t dst = fabs(src0); Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* nir/spirv: Use unreachable("...") rather than assert(!"...")Matt Turner2017-08-292-13/+13
| | | | | | | | Quiets a number of uninitialized variable warnings in clang. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* compiler: Add $(WNO_OVERRIDE_INIT) to AM_CFLAGSMatt Turner2017-08-291-0/+1
| | | | | | | nir_intrinsics.h does this a lot, causing lots of warnings from clang. Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util: move string_to_uint_map to glslEmil Velikov2017-08-299-7/+228
| | | | | | | | | | | | | | | | | | The functionality is used by glsl and mesa. With the latter already depending on the former. With this in place the src/util/ static library libmesautil.la no longer has a C++ dependency. Thus objects which use it (like libEGL) don't need the C++ link. Cc: "17.2" <[email protected]> Fixes: 02cc35937277 ("egl/wayland: Use linux-dmabuf interface for buffers") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101851 Signed-off-by: Emil Velikov <[email protected]> Suggested-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Tested-by: Mike Lothian <[email protected]> Tested-by: James Harvey <[email protected]>
* nir: Fix system_value_from_intrinsic for subgroupsJason Ekstrand2017-08-281-4/+4
| | | | | | | A couple of the cases were backwards Reviewed-by: Matt Turner <[email protected]> Cc: [email protected]
* nir: Fix some whatespaceJason Ekstrand2017-08-281-5/+5
| | | | | | Somehow tabs got in there... Reviewed-by: Matt Turner <[email protected]>
* glsl: fix counting of vertex shader output slots used by explicit varsIlia Mirkin2017-08-281-1/+2
| | | | | | | | | | | | The argument to count_attribute_slots should only be set to true for vertex inputs, not for all vertex shader varyings. Fixes KHR-GL45.enhanced_layouts.varying_locations Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Cc: [email protected]
* glsl: fix glsl_struct_field size calculations for shader cacheNicolai Hähnle2017-08-251-7/+4
| | | | | | | | | | | | | | | | | | Found by address sanitizer: ==22621==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61400000cbd8 at pc 0x7f561610a4ff bp 0x7ffca85f9d50 sp 0x7ffca85f94f8 READ of size 344 at 0x61400000cbd8 thread T0 #0 0x7f561610a4fe (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x5f4fe) #1 0x7f560bb305a5 in memcpy /usr/include/x86_64-linux-gnu/bits/string3.h:53 #2 0x7f560bb305a5 in blob_write_bytes ../../../mesa-src/src/compiler/glsl/blob.c:136 #3 0x7f560be7d7ff in encode_type_to_blob ../../../mesa-src/src/compiler/glsl/shader_cache.cpp:153 #4 0x7f560be81222 in write_program_resource_data ../../../mesa-src/src/compiler/glsl/shader_cache.cpp:950 #5 0x7f560be81222 in write_program_resource_list ../../../mesa-src/src/compiler/glsl/shader_cache.cpp:1118 #6 0x7f560be81222 in shader_cache_write_program_metadata(gl_context*, gl_shader_program*) ../../../mesa-src/src/compiler/glsl/shader_cache.cpp:1407 #7 0x7f560b825fdb in link_program ../../../mesa-src/src/mesa/main/shaderapi.c:1163 Fixes: 073a84ff60db ("glsl: stop adding pointers from glsl_struct_field to the cache") Reviewed-by: Timothy Arceri <[email protected]>
* glsl: pass shader source keys to the disk cacheTimothy Arceri2017-08-252-9/+23
| | | | | | | We don't actually write them to disk here. That will happen in the following commit. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: rename mesa cache dir and introduce cache versioningTimothy Arceri2017-08-251-2/+4
| | | | | | | | | | | | | | | | | | Steam is already analysing cache items, unfortunatly we did not introduce a versioning mechanism for identifying structural changes to cache entries earlier so the only way to do so is to rename the cache directory. Since we are renaming it we take the opportunity to give the directory a more meaningful name. Adding a version field to the header of cache entries will help us to avoid having to rename the directory in future. Please note this is versioning for the internal structure of the entries as defined in disk_cache.{c,h} as opposed to the structure of the data provided to the disk cache by the GLSL compiler and the various driver backends. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: stop adding pointers from bindless structs to the cacheTimothy Arceri2017-08-241-4/+8
| | | | | | | This is so we always create reproducible cache entries. Consistency is required for verification of any third party distributed shaders. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: stop adding pointers from shader_info to the cacheTimothy Arceri2017-08-241-6/+25
| | | | | | | This is so we always create reproducible cache entries. Consistency is required for verification of any third party distributed shaders. Reviewed-by: Samuel Pitoiset <[email protected]>
* compiler: move pointers to the start of shader_infoTimothy Arceri2017-08-241-3/+3
| | | | | | | This will allow us to easily skip them when writting the struct to disk cache. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: always write a name/label string to the cacheTimothy Arceri2017-08-241-4/+7
| | | | | | | | | In the following patch we will stop writing the pointer to cache. Unfortunately adding empty strings to that cache seems to be the only thing we can do here once we no longer have the pointers. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: don't write uniform storage offset if there isn't oneTimothy Arceri2017-08-241-3/+10
| | | | | | | This is so we always create reproducible cache entries. Consistency is required for verification of any third party distributed shaders. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: add has_uniform_storage() helper to shader cacheTimothy Arceri2017-08-241-6/+13
| | | | Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: stop adding pointers from glsl_struct_field to the cacheTimothy Arceri2017-08-241-7/+38
| | | | | | | This is so we always create reproducible cache entries. Consistency is required for verification of any third party distributed shaders. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: stop adding pointers from gl_shader_variable to the cacheTimothy Arceri2017-08-241-12/+28
| | | | | | | This is so we always create reproducible cache entries. Consistency is required for verification of any third party distributed shaders. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: allow NULL to be passed to encode_type_to_blob()Timothy Arceri2017-08-241-0/+10
| | | | | | This will be used by the following commit. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl/linker: Make several functions not staticIan Romanick2017-08-222-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | copy_constant_to_storage, set_uniform_initializer, populate_consumer_input_sets, and get_matching_input are all used by tests in src/compiler/glsl/tests: glsl/tests/varyings_test.o: In function `link_varyings_single_simple_input_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:131: undefined reference to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' glsl/tests/varyings_test.o: In function `link_varyings_gl_ClipDistance_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:159: undefined reference to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' glsl/tests/varyings_test.o: In function `link_varyings_gl_CullDistance_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:186: undefined reference to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' glsl/tests/varyings_test.o: In function `link_varyings_single_interface_input_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:208: undefined reference to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' glsl/tests/varyings_test.o: In function `link_varyings_one_interface_and_one_simple_input_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:241: undefined reference to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' glsl/tests/varyings_test.o:src/compiler/glsl/tests/varyings_test.cpp:272: more undefined references to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' follow glsl/tests/varyings_test.o: In function `link_varyings_interface_field_doesnt_match_noninterface_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:289: undefined reference to `linker::get_matching_input(void*, ir_variable const*, hash_table*, hash_table*, ir_variable**)' glsl/tests/varyings_test.o: In function `link_varyings_interface_field_doesnt_match_noninterface_vice_versa_Test::TestBody()': src/compiler/glsl/tests/varyings_test.cpp:314: undefined reference to `linker::populate_consumer_input_sets(void*, exec_list*, hash_table*, hash_table*, ir_variable**)' src/compiler/glsl/tests/varyings_test.cpp:328: undefined reference to `linker::get_matching_input(void*, ir_variable const*, hash_table*, hash_table*, ir_variable**)' Fixes: ca73c3358c91 ("glsl: Mark functions static") Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: pass UseSTD430AsDefaultPacking to where it will be usedTimothy Arceri2017-08-228-42/+90
| | | | | | | Here we also make use of the UseSTD430AsDefaultPacking constant and call the new get_internal_ifc_packing() helper. Reviewed-by: Marek Olšák <[email protected]>
* glsl: add get_internal_ifc_packing() type helperTimothy Arceri2017-08-221-0/+21
| | | | | | | This is used to avoid code duplication when selecting the packing type for shared and packed layouts. Reviewed-by: Marek Olšák <[email protected]>
* glsl: Add prototype for udivmod64()Matt Turner2017-08-211-0/+3
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: Mark functions staticMatt Turner2017-08-2111-36/+36
| | | | | | Cuts 3224 bytes of .text Reviewed-by: Jordan Justen <[email protected]>
* glsl: Remove unused private fieldsMatt Turner2017-08-211-3/+1
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: add a few missing int64 constant propagation casesIlia Mirkin2017-08-182-0/+8
| | | | | | | | | | Fixes KHR-GL45.shader_ballot_tests.ShaderBallotAvailability, which causes some silly swizzles to appear, triggering this optimization to get hit. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Cc: [email protected]
* glsl: set old ldexp operand to NULL when loweringTimothy Arceri2017-08-181-0/+1
| | | | | | | | | This fixes an assert during IR validation in LLVMpipe. Fixes: e2e2c5abd279 (glsl: calculate number of operands in an expression once) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102274 Reviewed-by: Brian Paul <[email protected]> Tested-by: Brian Paul <[email protected]>
* glsl/ast: update rhs in addition to the var's constant_valueIlia Mirkin2017-08-151-1/+1
| | | | | | | | | | | | | We continue in the code to do some more things with the rhs, including setting a constant initializer. If the type is wrong, this causes some confusion down the line, leading to assertions. This makes sure that the rhs processing continues to flow as-if the type was correct to start with (even though the state has been marked as an error state). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101766 Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: [email protected]
* glsl: stop cloning builtin fuctions _mesa_glsl_find_builtin_function()Timothy Arceri2017-08-111-10/+1
| | | | | | | | | | | | | | | | | | | | | The cloning was introduced in f81ede469910d to fix a problem with shaders including IR that was owned by builtins. However the approach of cloning the whole function each time we reference a builtin lead to a significant reduction in the GLSL IR compilers performance. The previous patch fixes the ownership problem in a more precise way. So we can now remove this cloning. Testing on a Ryzen 7 1800X shows a ~15% decreases in compiling the Deus Ex: Mankind Divided shaders on radeonsi (which take 5min+ on some machines). Looking just at the GLSL IR compiler the speed up is ~40%. Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: pass mem_ctx to constant_expression_value(...) and friendsTimothy Arceri2017-08-1120-86/+159
| | | | | | | | | | | | | | | | | | | | The main motivation for this is that threaded compilation can fall over if we were to allocate IR inside constant_expression_value() when calling it on a builtin. This is because builtins are shared across the whole OpenGL context. f81ede469910d worked around the problem by cloning the entire builtin before constant_expression_value() could be called on it. However cloning the whole function each time we referenced it lead to a significant reduction in the GLSL IR compiler performance. This change along with the following patch helps fix that performance regression. Other advantages are that we reduce the number of calls to ralloc_parent(), and for loop unrolling we free constants after they are used rather than leaving them hanging around. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: use ralloc_str_append() rather than ralloc_asprintf_rewrite_tail()Timothy Arceri2017-08-111-31/+113
| | | | | | | | | | | | | | The Deus Ex: Mankind Divided shaders go from spending ~20 seconds in the GLSL IR compilers front-end down to ~18.5 seconds on a Ryzen 1800X. Tested by compiling once with shader-db then deleting the index file from the shader cache and compiling again. v2: - fix rebasing issue in v1 Reviewed-by: Thomas Helland <[email protected]>
* glsl: remove unused field from ir_callTimothy Arceri2017-08-111-5/+0
| | | | | Reviewed-by: Thomas Helland <[email protected]> Tested-by: Dieter Nützel <[email protected]>
* glsl: stop copying struct and interface member namesTimothy Arceri2017-08-1111-38/+31
| | | | | | | | | | | We are currently copying the name for each member dereference but we can just share a single instance of the string provided by the type. This change also stops us recalculating the field index repeatedly. Reviewed-by: Thomas Helland <[email protected]>
* glsl: tidy up get_num_operands()Timothy Arceri2017-08-112-14/+9
| | | | | | | | | | | Also add a comment that this should only be used by the ir_reader interface for testing purposes. v2: - fix grammar in comment - use unreachable rather than assert Reviewed-by: Thomas Helland <[email protected]>
* glsl: calculate number of operands in an expression onceTimothy Arceri2017-08-1120-27/+98
| | | | | | | | | | | | | | | | | | | Extra validation is added to ir_validate to make sure this is always updated to the correct numer of operands, as passes like lower_instructions modify the instructions directly rather then generating a new one. The reduction in time is so small that it is not really measurable. However callgrind was reporting this function as being called just under 34 million times while compiling the Deus Ex shaders (just pre-linking was profiled) with 0.20% spent in this function. v2: - make num_operands a unit8_t - fix unsigned/signed mismatches Reviewed-by: Thomas Helland <[email protected]>
* glsl: update the extensions/functions that are enabled for 460Samuel Pitoiset2017-08-072-17/+99
| | | | | | | | Other ones are either unsupported or don't have any helper function checks. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* spirv: Fix SpvImageFormatR16uiJason Ekstrand2017-08-021-1/+1
| | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Cc: "17.1 17.2" <[email protected]>
* glsl: recognize GLSL 4.60Samuel Pitoiset2017-08-023-3/+5
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: look up for transform feedback varyings after linkingJuan A. Suarez Romero2017-08-021-0/+7
| | | | | | | | | | | | | | Check if shaders have transform feedback varyings also after the post-link step. This fixes: KHR-GL45.enhanced_layouts.xfb_vertex_streams piglit/spec/arb_enhanced_layouts/gs-stream-location-aliasing v2: add claryfing comments (Timothy) Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: fix algebraic optimizationsConnor Abbott2017-08-011-2/+2
| | | | | | | | The optimizations are only valid for 32-bit integers. They were mistakenly firing for 64-bit integers as well. Cc: [email protected] Reviewed-by: Matt Turner <[email protected]>
* glsl: xfb_stride applies to buffers, not block membersJuan A. Suarez Romero2017-08-011-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we have an interface block like: layout (xfb_buffer = 0, xfb_offset = 0) out Block { vec4 var1; layout (xfb_stride = 48) vec4 var2; vec4 var3; }; According to ARB_enhanced_layouts spec: "The *xfb_stride* qualifier specifies how many bytes are consumed by each captured vertex. It applies to the transform feedback buffer for that declaration, whether it is inherited or explicitly declared. It can be applied to variables, blocks, block members, or just the qualifier out. [ ...] 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." This means xfb_stride actually applies to the buffer, and not to the individual components. In the above example, it means that var2 consumes 16 bytes, and var3 is at offset 32. This has been confirmed also by John Kessenich, the main contact for the ARB_enhanced_layouts specs, and also because this commit fixes: GL45.enhanced_layouts.xfb_block_member_stride This commit is in practice a revert of 598790e8564 (glsl: apply xfb_stride to implicit offsets for ifc block members). Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* st/mesa: get rid of st_glsl_typesNicolai Hähnle2017-07-311-1/+3
| | | | | | | It's a duplicate of glsl_type::count_attribute_slots. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* nir: add nir_lower_uniforms_to_ubo passNicolai Hähnle2017-07-313-0/+99
| | | | | | | | | | This is a further lowering of default-block uniform loads that transforms load_uniform intrinsics into load_ubo intrinsics. This simplifies the rest of the backend. v2: transform from load_uniform instead of straight from variables Reviewed-by: Eric Anholt <[email protected]>
* nir: add nir_lower_samplers_as_deref passNicolai Hähnle2017-07-315-0/+255
| | | | | | This pass is a replacement for the nir_lower_samplers pass, which has the advantage of keeping sampler references as derefs. This allows a unified treatment of texture instructions and image intrinsics in the backend.
* nir: add load_frag_coord system value intrinsicNicolai Hähnle2017-07-313-0/+6
| | | | | | | Some drivers prefer to treat gl_FragCoord as a system value rather than a fragment shader input, see Const.GLSLFragCoordIsSysVal. Reviewed-by: Jason Ekstrand <[email protected]>