Commit graph

8896 commits

Author SHA1 Message Date
Christian Gmeiner
a8a33ac5ae isaspec: Add bool_inv type to print inverted bools
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20144>
2023-12-16 14:34:18 +00:00
Job Noorman
6e7a61df4c nir: add _safe variants of nir_foreach_reg_load/store
Signed-off-by: Job Noorman <jnoorman@igalia.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26175>
2023-12-15 17:19:28 +00:00
Faith Ekstrand
1cf1b9d741 nir: Scalarize bounds checked loads and stores
Fixes: 39da1deb49 ("nir/lower_io: Add a bounds-checked 64-bit global address format")
Reviewed-by: M Henning <drawoc@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26526>
2023-12-15 03:53:54 +00:00
Caio Oliveira
81e3b28f78 compiler: Remove C++ static member pointers to builtin types
When we moved the bulk of glsl_type to C, these globals were
kept to avoid changes to compiler/glsl code in the MR.  Now that
landed, change the code to use the actual bultins directly.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26658>
2023-12-15 03:09:19 +00:00
Caio Oliveira
90e364edb0 compiler/types: Add a few more helpers to get builtin types
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26658>
2023-12-15 03:09:19 +00:00
Caio Oliveira
f17e23e116 compiler/glsl: Reduce scope of is_anonymous
This a GLSL parser specific detail, so move it there.  Also
add a comment pointing to where #anon prefix is used.

Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26656>
2023-12-13 15:44:40 +00:00
Friedrich Vock
f1817ab7e0 radv,vtn,driconf: Add and use radv_rt_ssbo_non_uniform workaround for Crysis 2/3 Remastered
Crysis 2 and 3 Remastered's RT shaders non-uniformly index into SSBO
descriptor arrays without specifying the NonUniformEXT qualifier on the
relevant access chains/load ops. This leads to artifacts around objects.

To add insult to injury, the game fails to provide a meaningful
applicationName/engineName in the Vulkan part of the DX11-Vulkan interop
solution used for RT. Both of these fields are set to "nvpro-sample"
(perhaps the code has been copied from NVIDIA's sample applications).
Therefore, fall back to executable name matching.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9883
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26391>
2023-12-12 21:16:39 +00:00
Karol Herbst
8c73b1eb90 nir/algebraic: add support for custom arguments
Those are passed as an optional argument and are declared as a list of
(type, name) tuples.

At the moment this can only be used for conditions.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26214>
2023-12-12 18:48:11 +00:00
Karol Herbst
c674db05e8 clc: use addMacroDef/Undef instead of -D/-U flags
It always felt weird having the extension management in two different
places. Later once we require LLVM-14 we might even be able to clean it up
a little more.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26641>
2023-12-12 14:24:48 +00:00
Lionel Landwerlin
f53748c481 nir: fixup nir_printf intrinsic description
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26505>
2023-12-12 11:11:10 +00:00
Lionel Landwerlin
dc3e69af1a nir/serialize: untangle printf serialization from a particular stage
This allows any stage to carry printf instructions.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26505>
2023-12-12 11:11:10 +00:00
Lionel Landwerlin
4e4a3820ab nir/divergence: handle printf intrinsic
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26505>
2023-12-12 11:11:10 +00:00
Lionel Landwerlin
f7ae92b868 nir: include printfs from linked shaders
Once lowered low enough, it's not always possible to tell what strings
are used. So include them all when linking another shader.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26505>
2023-12-12 11:11:10 +00:00
Lionel Landwerlin
81b3dea993 nir/clone: fix missing printf_info clone
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26505>
2023-12-12 11:11:10 +00:00
Lionel Landwerlin
603f039708 nir: make printf_info (de)serializer available
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26505>
2023-12-12 11:11:10 +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
Karol Herbst
7e78802028 clc: add support for cl_khr_subgroup_shuffle and shuffle_relative
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26504>
2023-12-11 23:08:51 +00:00
Eric Engestrom
c51e40dd8b spirv: add missing build dependency
Fixes: 59a72570b6 ("compiler: Move spirv into a module of its own")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10277
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26624>
2023-12-11 21:47:37 +00:00
Ian Romanick
7fce0a5598 nir: Handle divergence for decl_reg
Once decl_reg is handled, src[0].ssa->divergent will be properly set, so
load_reg and load_reg_indirect do not need special treatment.

shader-db can run to completion on HSW, IVB, and SNB now. No other
testing was done.

v2: Refactor nir_intrinsic_load_reg and nir_intrinsic_load_reg_indirect
handling. Suggested by Daniel Schürmann.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Fixes: 4fd257d20f ("nir: Properly handle divergence for load_reg")
Fixes: 6dbb5f1e07 ("intel/fs: rerun divergence analysis prior to convert_from_ssa")
Closes: #10233
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26436>
2023-12-11 17:10:51 +00:00
Jesse Natalie
37c0e8beda compiler/clc: Don't fail to parse SPIR-V if there's no kernels
It's valid to have library SPIR-V being parsed that has no entrypoints.
We still want to get spec constant info for them.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26582>
2023-12-11 16:28:28 +00:00
Faith Ekstrand
aac1e3f595 nir: Add a new has_fmulz_no_denorms flag
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26569>
2023-12-11 15:29:17 +00:00
Alyssa Rosenzweig
c43c90a5fa asahi: rewrite pointsize handling
In the wise words of Mike Blumenkrantz, "I hate gl_PointSize and so can you".

The mesa/st lowering won't mesh well with vertex shader epilogues, and it falls
over in various circumstances. I am too tired to go against the grain, so let's
just pretend to be a normal gallium driver and trust in the rasterizer CSO,
lowering point size internally. This properly handles transform feedback without
any hacks, both GL and GLES behaviours, etc.

Fixes:

   KHR-GL31.transform_feedback.capture_vertex_separate_test
   gl-2.0-large-point-fs

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
2023-12-09 12:08:39 -04:00
Alyssa Rosenzweig
5987e47a29 asahi: rework GS input assembly
in prep for tessellation (which will share the IA lowering), and for multidraw
indirect (which greatly complicates IA lowering with geom/tess).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
2023-12-09 12:08:39 -04:00
Karol Herbst
6979a1aa07 nir/opt_preamble: make load_workgroup_size handling optional
not all drivers support it being in the preamble, e.g. asahi.

Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
2023-12-09 10:56:37 -04:00
Marek Olšák
7d2faa88ab nir,radeonsi: add FLAGS into load_vector_arg_amd to record color input usage
This will be needed for gathering color usage from lowered PS.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26307>
2023-12-09 00:05:27 +00:00
Yonggang Luo
e7c614bd20 util,vulkan,mesa,compiler: Generate source files with utf8 encoding from mako template
This is for fixes the following error:
FAILED: src/vulkan/runtime/vk_synchronization_helpers.c src/vulkan/runtime/vk_synchronization_helpers.h
"C:\CI-Tools\msys64\mingw64\bin/python3.EXE" "../../src/vulkan/util/vk_synchronization_helpers_gen.py" "--xml" "../../src/vulkan/registry/vk.xml" "--out-c" "src/vulkan/runtime/vk_synchronization_helpers.c" "--beta" "false"

Traceback (most recent call last):
  File "C:/work/xemu/mesa/src/vulkan/util/vk_synchronization_helpers_gen.py", line 213, in main
    f.write(TEMPLATE_C.render(**environment))
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 15: illegal multibyte sequence

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26515>
2023-12-07 12:41:07 +00:00
Timothy Arceri
72ad0db505 glsl: remove now unused GLSL IR block linker
This is now done in the NIR linker instead.

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
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
Timothy Arceri
0c6272f97f glsl: support glsl linking in nir block linker
This added support for names and some extra validation that the
spirv linker does not require.

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
Timothy Arceri
c468aa6059 nir: add nir_fixup_deref_types()
This will be used to fix up types after arrays have been resized.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26534>
2023-12-07 03:05:09 +00:00
Yonggang Luo
72e30c8853 treewide: Avoid use align as variable, replace it with other names
align is a function and when we want use it, the align variable will shadow it
So replace it with other names

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25997>
2023-12-07 02:30:53 +00:00
Faith Ekstrand
d2ffcb6092 nir: Lower [su]dot_4x8_[ui]add_sat to [su]dot_4x8_[ui]add
Since nir_opt_algebraic runs on its own results, if the driver doesn't
have [su]dot_4x8_[ui]add then the [su]dot_4x8_[ui]add lowering rules
will kick in and lower that to what we had originally.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26533>
2023-12-06 23:15:33 +00:00
Faith Ekstrand
09fc5e1c4d nir: Split has_[su]dot_4x8 bits into regular and _sat versions
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26533>
2023-12-06 23:15:33 +00:00
Faith Ekstrand
22c60ea384 nir: Respect variable alignments in lower_vars_to_explicit_types
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26522>
2023-12-06 18:37:36 +00:00
Faith Ekstrand
629af540ca spirv: Plumb variable alignments through to NIR
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26522>
2023-12-06 18:37:36 +00:00
Rhys Perry
0cbe0d2968 nir/loop_analyze: support loops with min/max and non-add incrementation
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26225>
2023-12-06 15:58:36 +00:00
Rhys Perry
fc1ebc67b1 nir/loop_analyze: support umin and {u,i,f}max
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26225>
2023-12-06 15:58:36 +00:00
Rhys Perry
9591c36666 nir/loop_analyze: check min compatibility with comparison
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26225>
2023-12-06 15:58:36 +00:00
Rhys Perry
b6c2a5d48d nir/loop_analyze: fix vector basis/limit/comparison
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26225>
2023-12-06 15:58:36 +00:00
Rhys Perry
2f46773819 nir/loop_analyze: scalarize try_eval_const_alu
This is simpler, and users of this function expected scalar anyway.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26225>
2023-12-06 15:58:36 +00:00
Rhys Perry
7960588413 nir/loop_analyze: skip if basis/limit/comparison is vector
Replacement in try_eval_const_alu() doesn't work because the replacements
are always scalar. The callers also always give a scalar dest.

This is encountered when compiling a Redout shader under ASan.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Fixes: bc170e895f ("nir/loop_analyze: Use try_eval_const_alu and induction variable basis info")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26225>
2023-12-06 15:58:36 +00:00
Faith Ekstrand
2a28338aa8 compiler: Fix a comment
We're not using GL enums here anymore

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24821>
2023-12-05 23:12:32 +00:00
Faith Ekstrand
06257514c1 nir: Return a mesa_prim from gs_in_prim_for_topology
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
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
Karol Herbst
65de9bc81a clc: add dump_llvm debug options
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26524>
2023-12-05 22:45:53 +00:00
Karol Herbst
d9d398e652 clc: allow debug flag to be read from other files
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26524>
2023-12-05 22:45:53 +00:00
Alyssa Rosenzweig
65e431e61a nir/lower_idiv: Optimize idiv sign calculation
Save a comparison, and move out the comparison to be more backend friendly.
Saves 2 instrs on AGX (as the remaining comparison now fuses with bcsel).

Results on AGX, all affected shaders in asphalt9.

   total instructions in shared programs: 1813003 -> 1812611 (-0.02%)
   instructions in affected programs: 119646 -> 119254 (-0.33%)
   helped: 333
   HURT: 0
   Instructions are helped.

   total bytes in shared programs: 11870344 -> 11867208 (-0.03%)
   bytes in affected programs: 820888 -> 817752 (-0.38%)
   helped: 333
   HURT: 0
   Bytes are helped.

and on Mali-G57:

   total instructions in shared programs: 2677538 -> 2677205 (-0.01%)
   instructions in affected programs: 206923 -> 206590 (-0.16%)
   helped: 333
   HURT: 0
   Instructions are helped.

   total cvt in shared programs: 14667.50 -> 14662.30 (-0.04%)
   cvt in affected programs: 1953.64 -> 1948.44 (-0.27%)
   helped: 333
   HURT: 0
   Cvt are helped.

   total quadwords in shared programs: 1450664 -> 1450544 (<.01%)
   quadwords in affected programs: 5064 -> 4944 (-2.37%)
   helped: 15
   HURT: 0
   Quadwords are helped.

   total threads in shared programs: 53282 -> 53309 (0.05%)
   threads in affected programs: 27 -> 54 (100.00%)
   helped: 27
   HURT: 0
   Threads are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26489>
2023-12-05 21:46:26 +00:00
Faith Ekstrand
eda940c855 nak: Make barriers SSA-friendly
The NIR intrinsics now take and return a barrier whenever one is
modified instead of modifying in-place.  In NAK, we give the internal
instructions the same treatment and convert everything to use barrier
SSA values and RegRefs.  In nak_from_nir, we move all barriers to/from
GPRs.  We'll clean up the massive pile of OpBMov later.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26463>
2023-12-05 18:59:40 +00:00
Yonggang Luo
a9a2eabea8 glsl: move glsl_get_gl_type into glsl/linker_util.h
glsl_get_gl_type only accessed in src/compiler/glsl files, do not expose it
in libcompiler

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25879>
2023-12-05 16:16:55 +00:00