aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: fix gl_nir_set_uniform_initializers() for image arraysTimothy Arceri2020-02-141-1/+1
| | | | | | | | | | | | | The if was incorrectly checking for an image type on what could be an array of images. Here we change it to use the type stored in uniform storage which has already been stripped of arrays, this is what the above code for samplers does also. Fixes: 2bf91733fcb5 ("nir/linker: Set the uniform initial values") Reviewed-by: Alejandro Piñeiro <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3757> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3757>
* glsl: fix a memory leak with resource_setTapani Pälli2020-02-131-1/+3
| | | | | | | | | | | | | | | | | ==7265== 248 (120 direct, 128 indirect) bytes in 1 blocks are definitely lost in loss record 1,438 of 1,465 ==7265== at 0x483980B: malloc (vg_replace_malloc.c:309) ==7265== by 0x598A2AB: ralloc_size (ralloc.c:119) ==7265== by 0x598F861: _mesa_set_create (set.c:127) ==7265== by 0x599079D: _mesa_pointer_set_create (set.c:570) ==7265== by 0x58BD7D1: build_program_resource_list(gl_context*, gl_shader_program*, bool) (linker.cpp:4026) ==7265== by 0x548231B: st_link_shader (st_glsl_to_ir.cpp:170) ==7265== by 0x54DA269: _mesa_glsl_link_shader (ir_to_mesa.cpp:3119) Fixes: a6aedc66 ("st/glsl_to_nir: use nir based program resource list builder") Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3574> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3574>
* Rename nir_lower_constant_initializers to nir_lower_variable_initalizersArcady Goldmints-Orlov2020-02-121-2/+2
| | | | | | | | | This is naming is more clear as nir_variables can be initializes not just with a nir_constant but with a pointer to another nir_variable. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3047> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3047>
* glsl,nir: Switch the enum representing shader image formats to PIPE_FORMAT.Eric Anholt2020-02-056-59/+102
| | | | | | | | | | | | | | | | | This means you can directly use format utils on it without having to have your own GL enum to number-of-components switch statement (or whatever) in your vulkan backend. Thanks to imirkin for fixing up the nouveau driver (and a couple of core details). This fixes the computed qualifiers for EXT_shader_image_load_store's non-integer sizeNxM qualifiers, which we don't have tests for. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> (v3d) Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3355> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3355>
* gitlab-ci: Add ppc64el and s390x cross-build jobsMichel Dänzer2020-02-052-0/+2
| | | | | | | | | | | | | Using LLVM 8 for ppc64el and 7 for s390x (which hits some coroutine related issues with LLVM 8). There are some test failures we need to ignore for now. Also, the timeout needs to be bumped from the default 30s for some tests, because they can take longer under emulation. Reviewed-by: Adam Jackson <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3643>
* glsl: Use 'using' to be explicit about visitor overloadsKristian H. Kristensen2020-02-044-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Clang has a warning about overloading virtuals that triggers when a derived class defines a virtual function that's an overload of function in the base class. This kind of thing: struct chart; // let's pretend this exists struct Base { virtual void* get(char* e); }; struct Derived: public Base { virtual void* get(chart* e); // typo, we wanted to override the same function }; The solution is to use using Base::get; to be explicit about the intention to reuse the base class virtual. We hit this a lot with out glsl ir_hierarchical_visitor visitor pattern, so let's adds some 'using' to calm down the compiler. See-also: https://stackoverflow.com/questions/18515183/c-overloaded-virtual-function-warning-by-clang) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3686>
* compiler: add a new explicit interpolation modeSamuel Pitoiset2020-01-291-1/+1
| | | | | | | | | This introduces one more interpolation mode INTERP_MODE_EXPLICIT, which is needed for AMD_shader_explicit_vertex_parameter. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3578>
* util/hash_table: added hash functions for integer typesAnthony Pesch2020-01-2310-14/+14
| | | | | | | | | | | | | | | | | A few hash_table users roll their own integer hash functions which call _mesa_hash_data to perform the hashing which ultimately calls into XXH32 with a dynamic key length. When using small keys with a constant size the hash rate can be greatly improved by inlining XXH32 and providing it a constant key length, see: https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html Additionally, this patch removes calls to _mesa_key_hash_string and makes them instead call _mesa_has_string directly, matching the new integer hash functions. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3475>
* glsl_to_nir: update interface type properlyTimothy Arceri2020-01-231-2/+4
| | | | | | | | | | | | | Since 76ba225184ed the member variable types were being redefined but we assigned the old interface type to the variable. In a following patch series we will use the types to check if we are dealing with an interface instance when apply GLSL linking rules. Reviewed-by: Alejandro Piñeiro <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3468> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3468>
* glsl: count uniform components and storage better in nir linkingTimothy Arceri2020-01-231-4/+13
| | | | | | | | | This helps avoid incorrect validation error when linking glsl shaders and avoids assigning uniform storage slots that will never be used. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3468>
* glsl: fix check for matrices in blocks when using nir uniform linkerTimothy Arceri2020-01-231-4/+3
| | | | | | | | We need to stripe any arrays before checking the type. Here we just use the uniform type which has already be stripped. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3468>
* glsl: remove bogus assert in nir uniform linkingTimothy Arceri2020-01-231-1/+0
| | | | | | | | I'm not sure why this was first added but it causes an assert on any uniform matrix. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3468>
* compiler: Translate GLSL IR to NIR for new INTEL_shader_integer_functions2 ↵Ian Romanick2020-01-231-0/+30
| | | | | | | | | | expressions v2: Rebase on 272e927d0e9 ("nir/spirv: initial handling of OpenCL.std extension opcodes") Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/767>
* glsl: Add built-in functions for INTEL_shader_integer_functions2Ian Romanick2020-01-231-0/+311
| | | | | Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/767>
* glsl: Add new expressions for INTEL_shader_integer_functions2Ian Romanick2020-01-234-0/+126
| | | | | | | | | | | | | | | | v2: Re-write iadd64_saturate and isub64_saturate to avoid undefined overflow behavior. Also fix copy-and-paste bug in isub64_saturate. Suggested by Caio. v3: Avoid signed integer overflow for abs_sub(0, INT_MIN). Noticed by Caio. v4: Alternate fix for signed integer overflow for abs_sub(0, INT_MIN). I tried the previous methon in a small test program with -ftrapv, and it failed. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/767>
* mesa: Extension boilerplate for INTEL_shader_integer_functions2Ian Romanick2020-01-232-0/+3
| | | | | Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/767>
* nir: Rename nir_intrinsic_barrier to control_barrierJason Ekstrand2020-01-131-1/+1
| | | | | | | | This is a more explicit name now that we don't want it to be doing any memory barrier stuff for us. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>
* nir/glsl: Emit memory barriers as part of barrier()Jason Ekstrand2020-01-131-0/+12
| | | | | | | | | | | | The GLSL barrier() intrinsic does an implicit shared memory barrier in compute shaders and an implicit TCS patch output barrier in tessellation control shaders. We'd like NIR's barrier intrinsic to just be a control flow barrier and not have memory implications. To satisfy this, we need to add an extra memory barrier in front of each nir_intrinsic_barrier. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>
* glsl: fix potential bug in nir uniform linkerTimothy Arceri2020-01-121-7/+3
| | | | | | | | | | | The state value of main_uniform_storage_index will be wrong for add_parameter() when find_and_update_previous_uniform_storage() finds a uniform if there is more than 1 uniform used in multiple shader stages. The new code is also simpler. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: Fix software 64-bit integer to 32-bit float conversions.Francisco Jerez2020-01-101-22/+14
| | | | | | | | | | | | | | | | | | | | | | | | | The current implementation was broken for any integers between 2^24 and 2^30 (it would return zero for me on ICL). The reason is that for such integers we wouldn't take the 'if (0 <= shiftCount)' early return path, however 'shiftCount + 7' would be positive, leading to a negative 'count' argument passed to __shift64RightJamming(), which would give undefined results. This reworks the affected conversion functions to use either __shortShift64Left() or __shift64RightJamming() based on the sign of the final shift count, which should avoid the problem. In addition this should qualify as a clean-up/optimization -- This implementation of the conversion functions translates to 7 instructions less than the original on Intel hardware. This fixes the 'KHR-GL46.shader_ballot_tests.ShaderBallotFunctionBallot' conformance tests on soft fp64 hardware with large enough subgroup size (>16). Fixes: d5cf6e92b4f7 "glsl: Add built-in functions to do uint64_to_fp32(uint64_t)" Fixes: c9d333a6b76e "glsl: Add built-in functions to do int64_to_fp32(int64_t)" Cc: Sagar Ghuge <[email protected]> Reviewed-by: Sagar Ghuge <[email protected]>
* glsl: call calculate_subroutine_compat() from the nir linkerTimothy Arceri2020-01-102-2/+2
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: move calculate_subroutine_compat() to shared linker codeTimothy Arceri2020-01-103-37/+41
| | | | | | We will make use of this in the nir linker in the following patch. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: call uniform resource checks from the nir linkerTimothy Arceri2020-01-102-1/+2
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: move uniform resource checks into the common linker codeTimothy Arceri2020-01-103-80/+86
| | | | | | We will call this from the nir linker in the following patch. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: call check_subroutine_resources() from the nir linkerTimothy Arceri2020-01-102-1/+2
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: move check_subroutine_resources() into the shared util codeTimothy Arceri2020-01-103-15/+20
| | | | | | We will make use of this in the nir linker in the following patch. Reviewed-by: Tapani Pälli <[email protected]>
* spirv,nir: add new lod parameter to image_{load,store} intrinsicsSamuel Pitoiset2020-01-091-0/+5
| | | | | | | | | | | | SPV_AMD_shader_image_load_store_lod allows to use a lod parameter with OpImageRead, OpImageWrite and OpImageSparseRead. According to the specification, this parameter should be a 32-bit integer. It is initialized to 0 when no lod parameter is found during SPIR-V->NIR translation. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* glsl: use nir version of check_image_resources() for nir linkerTimothy Arceri2020-01-072-1/+2
| | | | Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: add check_image_resources() for the nir linkerTimothy Arceri2020-01-071-0/+38
| | | | | | | | This is adapted from the GLSL IR code but doesn't need to iterate over the IR. I believe this also fixes a potential bug in the GLSL IR code which potentially counts the same output twice. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: use nir linker to link atomicsTimothy Arceri2020-01-071-2/+5
| | | | Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: reorder link_and_validate_uniforms() callsTimothy Arceri2020-01-071-1/+1
| | | | | | This is required for the following commit. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: add new gl_nir_link_glsl() helperTimothy Arceri2020-01-072-0/+14
| | | | | | | | This will allow us to do some linking in NIR that was previously done by the GLSL IR linker. To start with this just has calls for linking atomics. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: add gl_nir_link_check_atomic_counter_resources()Timothy Arceri2020-01-072-0/+95
| | | | | | | This is pretty much a copy of link_check_atomic_counter_resources() updated to work with the NIR linker. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: rename gl_nir_link() to gl_nir_link_spirv()Timothy Arceri2020-01-072-5/+5
| | | | | | | | A NIR based glsl linking function will be too different to the spirv version to bother attempting any sharing. So lets change the name to be explicit. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl/nir: do not change an element index to have correct block nameAndrii Simiklit2020-01-061-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | When SSBO array is used with packed layout, both IR tree and as a result, NIR tree will be incorrect. In fact, the SSBO dereference indices won't match the array size in some cases like the following: "layout(packed, binding=1) buffer SSBO { vec4 a; } ssbo[3]; out vec4 color; void main() { color = ssbo[2].a; }" After linking the IR and then NIR will have an SSBO array definition with size 1 but dereference still will have index 2 and linked_shader->Program->sh.ShaderStorageBlocks will contain just SSBO with name "SSBO[2]" So this line should be removed at least as a workaround for now to avoid error like: Failed to find the block by name "SSBO[0]" Fixes: 810dde2a "glsl/nir: Add a pass to lower UBO and SSBO access" Signed-off-by: Andrii Simiklit <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]>
* glsl: fix a binding points assignment for ssbo/ubo arraysAndrii Simiklit2020-01-063-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is needed to be in agreement with spec requirements: https://github.com/KhronosGroup/OpenGL-API/issues/46 Piers Daniell: "We discussed this in the OpenGL/ES working group meeting and agreed that eliminating unused elements from the interface block array is not desirable. There is no statement in the spec that this takes place and it would be highly implementation dependent if it happens. If the application has an "interface" in the shader they need to match up with the API it would be quite confusing to have the binding point get compacted. So the answer is no, the binding points aren't affected by unused elements in the interface block array." v2: - 'original_dim_size' field moved above to keep the struct packed better on 64-bit - added a comment for 'total_num_array_elements' field - fixed a binding point calculations for SSBOs array of arrays ( Ian Romanick <[email protected]> ) - fixed binding point calculations for non-packed SSBOs v3: - rename 'total_num_array_elements' to 'aoa_size' ( Jason Ekstrand <[email protected]> ) - rename 'boffset' to 'binding_stride' ( Alejandro Piñeiro <[email protected]> ) Fixes: 8cf1333b "glsl: link uniform block arrays of arrays" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109532 Reported-By: Ilia Mirkin <[email protected]> Tested-by: Fritz Koenig <[email protected]> Signed-off-by: Andrii Simiklit <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]>
* glsl: fix an incorrect max_array_access after optimization of ssbo/uboAndrii Simiklit2020-01-061-0/+1
| | | | | | | | | | | | | This is needed to fix these tests: piglit.spec.arb_shader_storage_buffer_object.compiler.unused-array-element_frag piglit.spec.arb_shader_storage_buffer_object.compiler.unused-array-element_comp Fixes: 8cf1333b "glsl: link uniform block arrays of arrays" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109532 Reported-By: Ilia Mirkin <[email protected]> Tested-by: Fritz Koenig <[email protected]> Signed-off-by: Andrii Simiklit <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]>
* glsl: Set .flat for gl_FrontFacingAlyssa Rosenzweig2019-12-301-4/+7
| | | | | | | | | It is a boolean. Signed-off-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3237> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3237>
* st/glsl_to_nir: use nir based program resource list builderTimothy Arceri2019-12-134-5/+12
| | | | | | | | | | | | | | | | | Here we use the NIR based builder to add everything to the resource list execpt for SSO packed varyings. Since the details of those varyings get lost during packing we leave the special handing to the GLSL IR pass for now. In order to do this we add some bools to the build resource list functions. Using the NIR based resource list builder gets us a step closer to using a native NIR based linker. It should also be faster than the GLSL IR builder, one because the NIR optimisations should mean we add less entries due to better optimisations, and two because nir gives us better lists to work with and we don't need to walk the entire IR to find the resources. Ack-by: Alejandro Piñeiro <[email protected]>
* glsl: add subroutine support to nir_build_program_resource_list()Timothy Arceri2019-12-131-2/+31
| | | | | | | This is required so we can use the NIR linker to link GLSL in addition to spirv. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: add support for named varyings in nir_build_program_resource_list()Timothy Arceri2019-12-131-15/+286
| | | | | | | | | | | This adds support for adding names of varying to the resource list which is required for us to use this function with the glsl linker. Support for names is optional for spirv which is why it had not been added yet. This is mostly a copy of the GLSL IR code adapted to nir. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: copy the new data fields when converting to nirTimothy Arceri2019-12-131-0/+4
| | | | | | | These fields added in the previous commit will be used to make use of a NIR based GLSL linker. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: copy the how_declared field when converting to nirTimothy Arceri2019-12-131-0/+10
| | | | | | This is needed to make use of nir_build_program_resource_list(). Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: move nir_remap_dual_slot_attributes() call out of glsl_to_nir()Timothy Arceri2019-12-131-7/+0
| | | | | | | | | In order to be able to implement a NIR based glsl linker we need to build the program resource list with NIR. This change delays the remaping so that a later commit can call the NIR based resource list builder. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl/nir: iterate the system values list when adding varyingsTimothy Arceri2019-12-051-25/+36
| | | | | | | | | | | | Iterate the system values list when adding varyings to the program resource list in the NIR linker. This is needed to avoid CTS regressions when using the NIR to build the GLSL resource list in an upcoming series. Presumably it also fixes a bug with the current ARB_gl_spirv support. Fixes: ffdb44d3a0a2 ("nir/linker: Add inputs/outputs to the program resource list") Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl/tests: Use splitlines() instead of strip()Michel Dänzer2019-12-051-2/+2
| | | | | | | | | strip() removes leading and trailing newlines, but leaves newlines between multiple lines in the string. This could cause failures when comparing the output of cross-compiled Windows binaries (producing Windows-style newlines) to the expected output with Unix-style newlines. Reviewed-by: Dylan Baker <[email protected]>
* glsl: make use of active_shader_mask when building resource listTimothy Arceri2019-12-051-12/+1
| | | | | | | This allows us to avoid walking the entire IR looking for used uniforms. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: don't set uniform block as used when its notTimothy Arceri2019-12-052-2/+10
| | | | | | | | | | | The spec requires unused uniform block to be set as active in the program resource list. To support this we tell opt dead code not to remove them. However we can mark them as unused internally and avoid unnecessarily state changes. This change is also required for the folowing clean-up patch. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: move calculate_array_size_and_stride() to link_uniforms.cppTimothy Arceri2019-12-052-216/+218
| | | | | | | | This is where all the other uniform values are populated so it makes much more sense here. Moving it will also allow us to better share code between the NIR and GLSL IR resource list builders. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: additional interface redeclaration check for SSO programsTapani Pälli2019-12-041-0/+54
| | | | | | | | | | | Patch adds additional linker check for SSO programs to make sure they are redeclaring built-in blocks as required by the desktop spec. This fixes following Piglit tests: arb_separate_shader_objects/linker/pervertex-* Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>