Timothy Arceri
c2066d4685
glsl: call new nir resize_tes_inputs() pass
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28538 >
2024-04-06 05:56:04 +00:00
Timothy Arceri
d1c11d957a
glsl: switch to NIR block validation
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28538 >
2024-04-06 05:56:04 +00:00
Timothy Arceri
20db9b77aa
glsl: move invariant builtin validation to the nir linker
...
We don't attempt to recreate a nir implementation of the symbol table
instead here we simply use location to find the variables we need to
validate.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28142 >
2024-03-15 00:01:34 +00:00
Timothy Arceri
182bff5c05
glsl: remove unrequired do_lower_jumps() call
...
We were using this to remove unreachable instructions following
jumps. The previous patch allowed glsl to nir to handle these
instructions so this call is no longer needed.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27288 >
2024-03-12 01:43:03 +00:00
Timothy Arceri
8ceb10a1bd
glsl: make use of nir lower discard flow
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28005 >
2024-03-07 04:02:45 +00:00
Timothy Arceri
eefd836ebc
glsl: make use of nir recursion detection
...
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27841 >
2024-03-04 05:40:55 +00:00
Timothy Arceri
39052dabf9
glsl: don't inline functions in glsl ir
...
Everthing is now in place for nir and glsl to nir to handle this
stuff for us.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27108 >
2024-03-04 11:31:21 +11:00
Timothy Arceri
c6c150b4cd
glsl_to_nir: support conversion of opaque function params
...
Here we can assume anything that is not an input is bindless.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27108 >
2024-03-04 11:31:21 +11:00
Timothy Arceri
de7574f70a
glsl_to_nir: support conversion of struct/array function returns
...
This adds support for array and struct function returns in the glsl
to nir pass allowing us to avoid extra calls to the glsl IR
optimisation loop.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27108 >
2024-03-04 11:31:20 +11:00
Timothy Arceri
fac9b1c594
glsl_to_nir: support conversion of struct/array function params
...
This adds support for array and struct function params in the glsl
to nir pass allowing us to avoid extra calls to the glsl IR
optimisation loop.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27108 >
2024-03-04 11:31:20 +11:00
Timothy Arceri
0f0fa64eed
glsl: move some lowering to the compiler
...
Rather than doing this lowering potentially multiple times when a
shader is relinked we can instead do it once in the compiler.
This change also gets us closer to converting to NIR at compile
time.
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27690 >
2024-02-22 05:26:16 +00:00
Timothy Arceri
ec4990ef41
glsl: remove now unused GLSL IR validate_geometry_shader_emissions()
...
We now use the nir version of this validation pass instead.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27377 >
2024-02-01 01:53:15 +00:00
Timothy Arceri
ce3420394c
glsl: use nir version of geom stream validation
...
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27377 >
2024-02-01 01:53:15 +00:00
Caio Oliveira
d06f0305f6
glsl: Use glsl_type C helpers
...
Acked-by: Jesse Natalie <jenatali@microsoft.com >
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26707 >
2023-12-22 06:51:01 -08:00
Timothy Arceri
52dbf44d2e
glsl: add support for inout params to glsl_to_nir()
...
Supporting these means we don't have to depend on calling the GLSL
IR optimisation loop for shaders that contain these parameter types.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26755 >
2023-12-20 01:47:27 +00:00
Timothy Arceri
3d3ba9f428
glsl: move glsl ir lowering out of glsl_to_nir()
...
The main motivation for doing this is that some tests and even the
st tracker linking code dump out the GLSL IR for debugging before
glsl_to_nir() is called expecting it to already be in its final
form. Moving these to the linker makes those assumptions true.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26755 >
2023-12-20 01:47:27 +00:00
Timothy Arceri
37e83a93d7
glsl: remove some unused linker code
...
These were missed when removing code in 72ad0db505 .
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26747 >
2023-12-19 23:45:30 +00:00
Timothy Arceri
4584acca6b
glsl: tidy up validation loop in linker
...
There is no need to have a separate loop to determine the first stage in
the shader program. Previously there were other users of this but since
this is the last remain user this patch changes the code to simply detect
the first stage directly.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26747 >
2023-12-19 23:45:30 +00:00
Timothy Arceri
5147e9a26e
glsl: combine shader stage loops in linker
...
The gs validation that was run between these loops can be run after
merging them without any issue.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26628 >
2023-12-12 02:28:33 +00:00
Timothy Arceri
fe44414662
glsl/st: move remaining glsl ir lowering to linker
...
This is a tidy up but also allows us to drop an additional
validate_ir_tree() call.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26628 >
2023-12-12 02:28:33 +00:00
Timothy Arceri
32f274768e
glsl: use new nir based block linker
...
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26534 >
2023-12-07 03:05:10 +00:00
Faith Ekstrand
b97003e49a
glsl: Properly remap GL_* to MESA_PRIM
...
Instead of blatantly assuming with no assert that they're the same, add
a remap function. Also, be more careful about which enum we use where.
In the AST, we use GLenum and GL_FOO because we also need GL_ISOLINES.
When we translate to shader info, GS gets translated into mesa_prim
and tessellation gets translated into tess_primitive_mode which has
ISOLINES as a valid primitive value.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24821 >
2023-12-05 23:12:32 +00:00
Timothy Arceri
cdf0ed8960
glsl: use the nir based lower_named_interface_blocks()
...
Because we are now doing the lowering in NIR we need to move the code
that sets the compact flag on some builtin vars out of the glsl to nir
pass.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26001 >
2023-11-30 03:45:07 +00:00
Timothy Arceri
33c2b64aa3
glsl: switch to NIR distance lowering pass
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25860 >
2023-11-21 00:45:21 +00:00
Timothy Arceri
2e7514cfa8
glsl: remove now unused varying linker code
...
All of this varying linking code has now been ported to the NIR linker.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25371 >
2023-09-28 13:55:16 +00:00
Timothy Arceri
36e49c162c
glsl: switch to nir linkers cross_validate_outputs_to_inputs()
...
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25371 >
2023-09-28 13:55:16 +00:00
Timothy Arceri
7b744bb8df
glsl: switch to nir validate_first_and_last_interface_explicit_locations()
...
Use the new nir version. The glsl ir version will be removed in the
following patch.
Reviewed-by: Emma Anholt <emma@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25318 >
2023-09-22 00:41:18 +00:00
Caio Oliveira
bf01000a50
compiler/types: Use glsl_get_type_name() to access the type name
...
This will allow us later to store builtin names in a different way.
Reviewed-by: Adam Jackson <ajax@redhat.com >
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25191 >
2023-09-16 15:17:01 +00:00
Timothy Arceri
718699b9f0
glsl: remove field from gl_shader_program
...
We don't need to carry this value around, its only used a single time in
the linker. Instead simply extract it from gl_shader when we need it.
Reviewed-by: Dave Airlie <airlied@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25105 >
2023-09-13 03:44:40 +00:00
Timothy Arceri
80c001013c
glsl: do vs attribute validation in NIR linker
...
This allows us to tidy up the code and call the attribute location
code a single time rather than doing a "dry run".
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24035 >
2023-07-10 12:48:01 +10:00
Timothy Arceri
ac2b3cf7ef
glsl: remove glsl ir optimisation loop from linker
...
We no longer need to call this here and can depend on the glsl_to_nir
pass to call it and clean up anything it cannot handle. Everything
else can now depend on the nir optimisation passes.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:07 +00:00
Timothy Arceri
ed3fe89562
glsl: move store_fragdepth_layout() to nir linker
...
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:07 +00:00
Timothy Arceri
e8c2c59372
glsl: drop link_invalidate_variable_locations()
...
All this code does is reinitialise the values to what the original
ir_variable() call already set them too. This code is very old dating
to the initial glsl compiler support, it has probably been unrequired
for a long time now.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:07 +00:00
Timothy Arceri
ee68c633e9
glsl: set last_vert_prog in the nir linker
...
Another step to removing the GLSL IR linker
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:07 +00:00
Timothy Arceri
0d7b5f8b30
glsl: inline link_varyings()
...
Most code has already been moved to the NIR linker.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:06 +00:00
Timothy Arceri
06f3988c58
glsl: move disable_varying_optimizations_for_sso() to NIR linker
...
Reviewed-by: Emma Anholt <emma@anholt.net >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:06 +00:00
Timothy Arceri
fa56e911b8
glsl: call assign_attribute_or_color_locations() in NIR linker
...
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846 >
2023-07-06 01:21:06 +00:00
Yonggang Luo
12256136e0
compiler: Rename shader_prim to mesa_prim and replace all usage of pipe_prim_type with mesa_prim
...
This is a prepare step to remove depends on p_defines.h in src/util/*
This is done by:
replace pipe_prim_type with mesa_prim
replace shader_prim with mesa_prim
replace PIPE_PRIM_MAX with MESA_PRIM_COUNT
replace SHADER_PRIM_ with MESA_PRIM_
replace PIPE_PRIM_ with MESA_PRIM_
This patch only replace code only
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Acked-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23369 >
2023-06-03 03:29:03 +00:00
Timothy Arceri
5a29af262c
glsl: move some GL ES checks to the NIR linker
...
Eventually we should aim to remove the GLSL IR linker.
Reviewed-by: Emma Anholt <emma@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22305 >
2023-04-06 08:07:35 +00:00
Emma Anholt
84006587d7
glsl: Delete the lower_tess_level pass.
...
NIR i/o lowering and sysval lowering can handle the compact var fine at
this point.
Affects: nouveau, virgl, svga, radeonsi, r600, llvmpipe. Does not affect
PIPE_CAP_NIR_COMPACT_ARRAYS drivers like crocus, iris, d3d12, freedreno,
zink.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21940 >
2023-03-29 16:06:03 +00:00
volodymyr.o
47e7b49c61
mesa ctx->API --> _mesa_is_foo(ctx)
...
replaces direct API checks with _mesa_is_...() checks
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8340
Signed-off-by: Volodymyr Obohzyn volodymyr.obozhyn@globallogic.com
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Reviewed-by: Eric Engestrom <eric@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21556 >
2023-03-20 06:39:57 +00:00
Patrick Lerda
b2c340c106
mesa/st: fix possible crash related to arb invalid memory access
...
This invalid memory access is a consequence of wrong assumptions,
for instance:
"prog->sh.data is NULL if it's ARB_fragment_program"
This issue is triggered with piglit/fp-formats -auto -fbo:
==9747==ERROR: AddressSanitizer: heap-use-after-free on address 0x007f7c812d90 at pc 0x007f833c09f8 bp 0x007fd7eca750 sp 0x007fd7eca768
READ of size 4 at 0x007f7c812d90 thread T0
#0 0x7f833c09f4 in st_get_sampler_views ../src/mesa/state_tracker/st_atom_texture.c:109
#1 0x7f833c0b48 in update_textures ../src/mesa/state_tracker/st_atom_texture.c:266
#2 0x7f82b2d120 in st_validate_state ../src/mesa/state_tracker/st_util.h:128
#3 0x7f82b2d120 in prepare_draw ../src/mesa/state_tracker/st_draw.c:88
#4 0x7f82b2de64 in st_draw_gallium ../src/mesa/state_tracker/st_draw.c:141
#5 0x7f83105940 in _mesa_draw_arrays ../src/mesa/main/draw.c:1202
#6 0x7f8d5fa5cc in piglit_draw_rect_from_arrays piglit/tests/util/piglit-util-gl.c:711
#7 0x7f8d5fac34 in piglit_draw_rect_custom piglit/tests/util/piglit-util-gl.c:833
#8 0x4019e0 in piglit_display piglit/tests/shaders/fp-formats.c:67
#9 0x7f8d643fc4 in run_test piglit/tests/util/piglit-framework-gl/piglit_fbo_framework.c:52
#10 0x401624 in main piglit/tests/shaders/fp-formats.c:39
Signed-off-by: Patrick Lerda <patrick9876@free.fr >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21175 >
2023-02-10 04:45:29 +00:00
Emma Anholt
24607ce7d3
glsl: Remove lower_vec_index_to_swizzle.
...
GLSL's lower_vector_derefs already does this, and even if it didn't
nir_vector_extract() would when glsl-to-nir happens.
No effect on freedreno shader-db.
Reviewed-by: Adam Jackson <ajax@redhat.com >
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18466 >
2022-10-03 17:18:31 +00:00
Emma Anholt
7662a5e9d3
mesa: Remove PIPE_CAP_CS_DERIVED_SYSTEM_VALUES_SUPPORTED/lower_cs_derived.
...
We have fine NIR lowering for this (already called from mesa/st), no need
for a separate GLSL pass.
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com >
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18361 >
2022-09-06 17:11:14 +00:00
Emma Anholt
5f66a927ec
gallium,glsl: Delete PIPE_CAP_VERTEXID_NOBASE and lower_vertex_id.
...
Every driver uses the nir_lower_system_values path now.
Reviewed-by: Rob Clark <robdclark@chromium.org >
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18327 >
2022-08-31 22:57:03 +00:00
Emma Anholt
f075376823
glsl: Use the same NIR path for shared mem lowering as SPIRV does.
...
Now that we have no non-NIR drivers, we can retire the old code. We just
need to pass the variable accesses through to it.
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com >
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17610 >
2022-07-20 19:32:48 +00:00
Timothy Arceri
893b4d98f8
glsl: inline do_common_optimization() call
...
The function was previously a helper for when some drivers still
called the GLSL IR optimisations in a loop. No drivers do that
anymore.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16924 >
2022-06-08 22:58:50 +00:00
Timothy Arceri
d09a37ef54
glsl: remove never true do_dead_code() parameter
...
Since we have now switched all drivers to using NIR and therefore
the NIR based uniform linker this param never needs to be set to
true so remove it.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16924 >
2022-06-08 22:58:50 +00:00
Timothy Arceri
4237932685
glsl: tidy up link_varyings_and_uniforms()
...
All uniform linking is now done via nir based linker not via this
code so we drop that from its name. We also drop a bunch of unused
parameters.
Reviewed-by: Emma Anholt <emma@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16880 >
2022-06-07 01:11:19 +00:00
Timothy Arceri
f00be793e4
glsl: drop extra optimise swizzles call
...
As per the comment this was meant to tidy things up after varying
linking but varying linking has been moved into a nir based linker
so this extra call is no longer needed.
This optimisation pass is still called in the regular glsl ir
optimisation loop.
No shader-db change on Iris (BDW).
Reviewed-by: Emma Anholt <emma@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16880 >
2022-06-07 01:11:19 +00:00