summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* 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]>
* 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 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]>
* 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]>
* 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]>
* glsl: small builtin inline tidy upTimothy Arceri2017-07-271-4/+4
| | | | Reviewed-by: Samuel Pitoiset <[email protected]>
* compiler: move glsl_interface_packing enum to shader_enums.hTimothy Arceri2017-07-261-10/+1
| | | | | | This allows us to drop the duplicate gl_uniform_block_packing enum. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: rework misleading block layout codeTimothy Arceri2017-07-231-4/+4
| | | | | | | | | | | From the ARB_uniform_buffer_object spec: ""shared" uniform blocks, the default layout, ..." This doesn't fix anything as the default layout is already applied at this point but fixes the misleading code/comment. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: remove placeholder commentTimothy Arceri2017-07-231-4/+0
| | | | | | | | This was added in 2d03f48a65a666 and seems like it was intended as a TODO comment in a function stub rather than a useful code comment. Reviewed-by: Samuel Pitoiset <[email protected]>
* nir: Add intrinsics from ARB_shader_ballotMatt Turner2017-07-201-0/+45
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add intrinsics from ARB_shader_group_voteMatt Turner2017-07-201-0/+22
| | | | | | | | These are intrinsics rather than opcodes, because they operate across channels. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: disable array splitting for AoATimothy Arceri2017-07-191-0/+23
| | | | | | | | | | While it produces functioning code the pass creates worse code for arrays of arrays. See the comment added in this patch for more detail. V2: skip splitting of AoA of matrices too. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: check if any of the named builtins are available firstIlia Mirkin2017-07-053-4/+14
| | | | | | | | | | | | | | | | | | | | | _mesa_glsl_has_builtin_function is used to determine whether any variant of a builtin are available, for the purpose of enforcing the GLSL ES 3.00+ rule that overloads or overrides of builtins are disallowed. However the builtin_builder contains information on all builtins, irrespective of parse state, or versions, or extension enablement. As a result we would say that a builtin existed even if it was not actually available. To resolve this, first check if at least one signature is available for a builtin before returning true. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101666 Signed-off-by: Ilia Mirkin <[email protected]> Cc: [email protected] Reviewed-by: Timothy Arceri <[email protected]> Acked-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl_to_nir: zero-initialize var->data.descriptor_setNicolai Hähnle2017-07-051-0/+1
| | | | | | | This is convenient for backends that support both Vulkan and OpenGL while lowering samplers to derefs with nir_lower_samplers_as_deref. Reviewed-by: Timothy Arceri <[email protected]>
* glsl/blob: add valgrind checks that written data is definedNicolai Hähnle2017-07-051-0/+12
| | | | | | | | | | | | | Undefined data will eventually trigger a valgrind error while computing its CRC32 while writing it into the disk cache, but at that point, it is basically impossible to track down where the undefined data came from. With this change, finding the origin of undefined data becomes easy. v2: remove duplicate VALGRIND_CFLAGS (Emil) Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* glsl: explicitly zero out padding to gl_shader_variable bitfieldNicolai Hähnle2017-07-051-1/+4
| | | | | | | | | | Otherwise, the padding bits remain undefined, which leads to valgrind errors when storing the gl_shader_variable in the disk cache. v2: use rzalloc instead of an explicit padding member variable Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: look for multiple variables simultaneously with find_assignment_visitorNicolai Hähnle2017-07-051-41/+81
| | | | | | | | | | | | Save some passes over the IR. v2: redesign to make the users of find_assignments more readable v3: - fix missing ! - add some comments and make the num_found check more explicit (Timothy) Reviewed-by: Ian Romanick <[email protected]> (v1) Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simplify disable_varying_optimizations_for_ssoNicolai Hähnle2017-07-031-18/+11
| | | | | | | | | We always have stage == first and stage == last when first == last, so drop the special case. Also rephrase the comment to make the logic clearer. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: always print non-zero var->data.location_fracNicolai Hähnle2017-07-031-1/+1
| | | | | | | This is helpful in debugging varying assignments. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: do not call link_xfb_stride_layout_qualifiers() for fragment shadersJuan A. Suarez Romero2017-06-261-2/+5
| | | | | | | | | | | | | | | | | xfb only applies to the latest stage before the fragment shader, so there is no need to invoke it in the fragment shader. Fixes: KHR-GL45.enhanced_layouts.xfb_stride_of_empty_list KHR-GL45.enhanced_layouts.xfb_stride_of_empty_list_and_api v2: do reset only if shaders provide an explicit stride v3: do not call link_xfb_stride_layout_qualifiers() for fragment shaders (Timothy) Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Juan A. Suarez Romero <[email protected]>
* glsl: tidy up int declarationTimothy Arceri2017-06-221-2/+1
| | | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: fix typo in commentTimothy Arceri2017-06-221-1/+1
| | | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: Track whether uniforms are active per stageKenneth Graunke2017-06-223-0/+9
| | | | | | | | | | for finer granularity state flagging v2: Marek - use a bitmask, add shader cache support Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Update build instructions for int64.glslIan Romanick2017-06-201-2/+2
| | | | | | Trivial Signed-off-by: Ian Romanick <[email protected]>
* glsl: Fix indent in dump codeElie Tournier2017-06-201-7/+7
| | | | | Signed-off-by: Elie Tournier <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: gl_Max{Vertex,Fragment}UniformComponents exist in all desktop GL versionsIago Toral Quiroga2017-06-191-7/+9
| | | | | | | | | | The current implementation assumed that these were replaced in GLSL >= 4.10 by gl_Max{Vertex,Fragment}UniformVectors, however this is not true: both built-ins should be produced from GLSL 4.10 onwards. This was raised by new CTS tests that are in development. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add ir_variable::contains_bindless()Samuel Pitoiset2017-06-141-0/+11
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>