Timothy Arceri
065b45e4dc
glsl: remove linker.cpp
...
All functionality has now been converted to NIR or moved elsewhere.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:59 +00:00
Timothy Arceri
e4c3e7e0d8
glsl: rename link_shaders() -> link_shaders_init()
...
And move it to the linker util file.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:59 +00:00
Timothy Arceri
37ac8f5e79
glsl: move shader cache lookup call to st
...
The nir shader cache read call is just below this call now so the code
is easier to follow.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:59 +00:00
Timothy Arceri
b663eb83fe
glsl: move error and warning helpers to util file
...
These functions are already defined in linker_util.h so moving them here
is logical.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:59 +00:00
Timothy Arceri
19c27c39b4
glsl/mesa: remove ir_uniform.h
...
We moved its contents elsewhere in a previous patch.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:59 +00:00
Timothy Arceri
13301e2509
glsl: move resource_name_updated() to linker_util.cpp
...
We want to remove the old linker.cpp file in following patches so move
this util function to the util code file.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:58 +00:00
Timothy Arceri
08e25e091b
glsl/mesa: move uniform related shader structs to shader_types.h
...
This is where all the other uniform related structs are and these were
the only structs used by both the compiler and gl api that were defined
in the compiler code so lets move them to where everything else is
defined.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500 >
2024-10-04 00:10:58 +00:00
Iago Toral Quiroga
aac1c074cc
nir: make fclamp_pos_mali and fsat_signed_mali opcodes generic
...
V3D can use these too.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31480 >
2024-10-03 09:02:07 +00:00
Timothy Arceri
1c58f513c4
glsl: fix gl_{Clip,Cull}Distance error messages
...
The error message in the linker that checked
gl_MaxCombinedClipAndCullDistances would never be issued because the
compiler was already doing the check. I think the compiler might have
been done this way in the original commit d656736b as the linker
only sets the size when the clip/cull outputs are written so the
piglit test for this wouldn't have been triggered as it does not
write to the outputs.
Here we move the error to the compiler and fix things up so the
correct messages are triggered.
Fixes: d656736bbf ("glsl: Add arb_cull_distance support (v3)")
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31471 >
2024-10-03 06:59:47 +00:00
Faith Ekstrand
62a4fe861a
nir: Add an option to lower quad vote
...
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31470 >
2024-10-02 21:10:32 +00:00
Marek Olšák
f546df95a6
nir/opt_vectorize_io: fix skipped output vectorization if inputs were vectorized
...
Fixes: 2514999c9c - nir: add nir_opt_vectorize_io, vectorizing lowered IO
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31454 >
2024-10-02 20:26:23 +00:00
Job Noorman
4d50504b26
nir/lower_int64: add nir_intrinsic_rotate
...
Can simply be split into 32b ops.
Signed-off-by: Job Noorman <jnoorman@igalia.com >
Reviewed-by: Connor Abbott <cwabbott0@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31455 >
2024-10-02 06:35:49 +00:00
Job Noorman
e6a5c342da
nir/lower_int64: add nir_intrinsic_read_invocation_cond_ir3
...
Can simply be split into 32b ops.
Signed-off-by: Job Noorman <jnoorman@igalia.com >
Reviewed-by: Connor Abbott <cwabbott0@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31455 >
2024-10-02 06:35:49 +00:00
Job Noorman
584b63ecab
nir/load_store_vectorize: fix division by zero
...
Don't use glsl_get_explicit_stride as it may return 0 for vector types,
use nir_deref_instr_array_stride instead.
Signed-off-by: Job Noorman <jnoorman@igalia.com >
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31460 >
2024-10-02 05:53:57 +00:00
Rhys Perry
be64454710
nir/tests: test opt_loop_peel_initial_break with derefs in header block
...
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31324 >
2024-10-01 12:24:22 +00:00
Rhys Perry
0484044b1a
nir/opt_loop: rematerialize header block derefs in their use blocks
...
Otherwise, we could end up with phis of derefs.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com >
Fixes: 6b4b044739 ("nir/opt_loop: add loop peeling optimization")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31324 >
2024-10-01 12:24:22 +00:00
Christian Gmeiner
1421319dcf
compiler/rust: Copy MappedInstrs from NAK
...
Rename it to SmallVec, make it more generic and switch NAK
to it.
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31409 >
2024-10-01 11:33:35 +00:00
Gert Wollny
f19f1ec17b
nir/opt_algebraic: Allow two-step lowering of ftrunc@64 to use ffract@64
...
If ftrunc@64 is lowered by nir_lower_doubles it is turned into a
comparable long series of 32 bit operations. If the hardware
supports ffract@64 then nir_opt_algebraic can first lower ftrunc@64
to use some combinations with ffloor@64. They can then be turned
into a combination of fsub@64 and ffract@64 resulting in less
all-over instructions.
Fixes: 5218cff34b
nir/algebraic: avoid double lowering of some fp64 operations
Signed-off-by: Gert Wollny <gert.wollny@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29281 >
2024-09-30 23:51:02 +00:00
Kenneth Graunke
0b34a7aff0
nir: Don't generate single iteration loops to zero-initialize memory
...
If the stride we're adding to our loop counter is larger than the total
amount of shared local memory we're trying to initialize, we know the
loop will run at most one time. So we can skip emitting a loop.
Loop unrolling appears to be unable to detect this currently.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31312 >
2024-09-30 05:27:17 +00:00
Georg Lehmann
bb7e8d51b6
nir: delete nir_opt_reuse_constants
...
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31031 >
2024-09-27 05:19:16 +00:00
Georg Lehmann
60776f87c3
nir/opt_remove_phis: rematerialize constants
...
Foz-DB Navi31:
Totals from 749 (0.94% of 79395) affected shaders:
Instrs: 1224359 -> 1223722 (-0.05%); split: -0.07%, +0.02%
CodeSize: 6468392 -> 6466296 (-0.03%); split: -0.06%, +0.03%
Latency: 9764410 -> 9766457 (+0.02%); split: -0.01%, +0.03%
InvThroughput: 1017401 -> 1017380 (-0.00%); split: -0.03%, +0.03%
VClause: 19902 -> 19873 (-0.15%); split: -0.16%, +0.02%
SClause: 38441 -> 38424 (-0.04%); split: -0.05%, +0.01%
Copies: 86880 -> 86304 (-0.66%); split: -0.73%, +0.06%
Branches: 34206 -> 34159 (-0.14%); split: -0.14%, +0.01%
PreSGPRs: 45557 -> 45527 (-0.07%); split: -0.08%, +0.01%
PreVGPRs: 32406 -> 32408 (+0.01%)
VALU: 671633 -> 671533 (-0.01%); split: -0.02%, +0.01%
SALU: 155284 -> 154675 (-0.39%); split: -0.40%, +0.00%
VMEM: 27303 -> 27271 (-0.12%)
SMEM: 67490 -> 67455 (-0.05%)
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31031 >
2024-09-27 05:19:16 +00:00
Georg Lehmann
40fc85c15b
nir: make nir_instr_clone usable with load_const and undef
...
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31031 >
2024-09-27 05:19:16 +00:00
Georg Lehmann
a9f8089240
nir: replace nir_opt_remove_phis_block with a single source version
...
This is what callers actually want, and it simplifies nir_opt_remove_phis
because we can assume dominance meta data is valid.
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31031 >
2024-09-27 05:19:16 +00:00
Georg Lehmann
41e82b8b8e
nir: sink is_subgroup_invocation_lt_amd
...
Having it closer to the branches means we can eliminate an exec copy.
Foz-DB Navi31:
Totals from 11615 (14.63% of 79395) affected shaders:
Instrs: 6804372 -> 6804903 (+0.01%); split: -0.04%, +0.05%
CodeSize: 33684672 -> 33680584 (-0.01%); split: -0.07%, +0.05%
VGPRs: 578616 -> 578604 (-0.00%)
SpillSGPRs: 1506 -> 1304 (-13.41%)
Latency: 29817034 -> 29821320 (+0.01%); split: -0.03%, +0.05%
InvThroughput: 3581587 -> 3581217 (-0.01%); split: -0.02%, +0.01%
VClause: 124826 -> 124782 (-0.04%); split: -0.04%, +0.00%
SClause: 187916 -> 187645 (-0.14%); split: -0.27%, +0.13%
Copies: 520969 -> 510027 (-2.10%); split: -2.20%, +0.10%
PreSGPRs: 442584 -> 421344 (-4.80%)
VALU: 3810755 -> 3810267 (-0.01%); split: -0.01%, +0.00%
SALU: 763402 -> 752650 (-1.41%); split: -1.48%, +0.07%
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31184 >
2024-09-26 14:29:14 +00:00
Georg Lehmann
bcfc5c09fa
amd: add offset to is_subgroup_invocation_lt_amd
...
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31184 >
2024-09-26 14:29:13 +00:00
Marek Olšák
09e64e3682
nir/opt_shrink_vectors: shrink memory loads, not just IO
...
The problem with radeonsi+ACO is that UBO loads from vec4 uniforms using
only 1 component always load all 4 components. This fixes that.
We are only interested in shrinking UBO and SSBO loads, but I added more
intrinsics because why not.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29384 >
2024-09-26 03:01:38 +00:00
Timothy Arceri
f6e7520b13
glsl: remove now unused linker code
...
This has all be replaced by a nir based linker implementation.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
cbfc225e2b
glsl: switch to a full nir based linker
...
This commit does 3 things at once (3 squashed commits) as required
to make sure the commit doesn't break things.
1. convert to nir at compile time
2. enable full nir linking
3. switch standalone compiler to nir linker
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
5108a9a37d
glsl: set blake3 hash in standalone scaffolding
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
1c88ed6194
glsl: add lower_derivatives_without_layout() helper
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Georg Lehmann
ff4596ae61
spirv: explicitly lower derivatives to zero
...
To allow removal of the existing nir_builder lowering.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
721d23b8ff
glsl: add intrastage shader linking helpers for nir linker
...
Conversions of the existing glsl ir linking code to nir.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
fe9b93fc1c
nir: handle wildcard array deref
...
Here we add handling of wildcard array derefs when attempting to mark
an io as partially used rather than hitting an assert.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
6bb6b0e5ad
nir: add nir_intrinsic_deref_implicit_array_length intrinsic
...
This will be used to handle .length() calls on unsized arrays
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
083b4ffb78
glsl: add gl_nir_linker_size_arrays()
...
This will size implicitly size arrays during linking, replacing the glsl
ir version.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
a235da080e
glsl: add gl_nir_link_function_calls()
...
This will link functions combining multiple shaders from the same stage
into a single shader. Unlike alot of the glsl ir linker that has been
converted to NIR the logic here is completely different from the glsl ir
code that linked functions. The existing nir cloning code allows us to
implement this functionality in a much more eligant way than what glsl
ir was doing.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
60937b5286
nir: add implicit_conversion_prohibited field to nir_parameter
...
Will be used in link time validation in following patches.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
5645495156
nir: store variable mode in nir_parameter
...
This will be used by the nir glsl linker in following patches.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
89a2411c54
nir: serialize nir_parameter type
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
6ff3e87e5f
nir: add function in/outs to variable modes
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:44 +00:00
Timothy Arceri
f3da074dc3
glsl: move _mesa_glsl_can_implicitly_convert() to linker_util.cpp
...
Makes more sense here as its used by both the compiler and linker.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Timothy Arceri
1cb115abd2
nir: add nir_function_impl_clone_remap_globals()
...
This will be use by the glsl nir linker when we are combining
different shaders from the same shader stage that might have multiple
declarations of global variables across the different shaders.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Timothy Arceri
7a1061e0dd
nir: add max_ifc_array_access field to vars
...
This will be used in following patches by the nir based glsl
linker code.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Timothy Arceri
7c5b21c032
glsl: add support for converting global instructions to NIR
...
NIR doesn't really support global instructions such as global val
initilisation. So here we add functionality to glsl_to_nir() to
put these instructions into a temporary function that will be
later inlined into main.
We give the function a name starting with gl_mesa_tmp_ as functions
starting with gl_ are reserved and will not have any clashes with
user functions, we finish the name with the blake3 of the shader
source to avoid conflicts with multiple shaders attached to a single
stage.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Timothy Arceri
1fc9d5223e
glsl: make gl_nir_validate_intrastage_arrays() more flexible
...
This will allow us to use it before shaders from the same stage have
been linked and merged.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Timothy Arceri
ffbd763586
glsl: add gl_nir_validate_intrastage_interface_blocks()
...
This is a nir version of the existing glsl ir validation function.
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Timothy Arceri
90e76d34ff
mesa/glsl: add nir fields to the gl shader structs
...
Acked-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137 >
2024-09-25 09:39:43 +00:00
Georg Lehmann
e0bcab953d
nir: add amd shared append/consume
...
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31075 >
2024-09-19 16:21:47 +00:00
Boris Brezillon
eeb3512498
nir/lower_ssbo: Extend the load_ssbo_address intrinsic to pass an offset
...
On Mali(Valhall), the bounds checking can be done when in hardware, but
for this to work properly, we need to pass the offset to the
nir_load_ssbo_address() intrinsic.
Add an offset source to the intrinsic, and adjust the lowering pass
to conditionally lower the offset addition.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Acked-by: Eric R. Smith <eric.smith@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31164 >
2024-09-18 13:45:57 +00:00
Boris Brezillon
adadb097a3
nir/lower_ssbo: Add an option to conditionally lower loads
...
On Mali(Valhall), we have a way to load SSBO data without going through
an SSBO index -> global address translation, so let's provide a way
to tell nir_lower_ssbo() when it shouldn't lower loads.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Acked-by: Eric R. Smith <eric.smith@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31164 >
2024-09-18 13:45:57 +00:00