Faith Ekstrand
82fe981e35
nir,spirv: Add support for SPV_NV_shader_sm_builtins
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27154 >
2024-01-18 20:20:06 +00:00
Yonggang Luo
616c0cd067
compiler/spirv: vtn_add_printf_string support for handling OpBitcast
...
specifically, it's handling
%48 = OpBitcast %_ptr_UniformConstant_uchar %_str
%49 = OpBitcast %_ptr_UniformConstant_uchar %_str_1
; SPIR-V
; Version: 1.4
; Generator: Khronos SPIR-V Tools Linker; 0
; Bound: 53
; Schema: 0
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %2 "main_test" %_str %_str_1
%5 = OpString "kernel_arg_type.main_test.float*,uint*,"
%6 = OpString "kernel_arg_type_qual.main_test.,,"
OpSource OpenCL_C 102000
OpName %_str ".str"
OpName %_str_1 ".str.1"
OpName %main_test "main_test"
OpName %src "src"
OpName %dest "dest"
OpName %entry "entry"
OpName %src_addr "src.addr"
OpName %dest_addr "dest.addr"
OpName %arrayidx "arrayidx"
OpName %call "call"
OpName %src_0 "src"
OpName %dest_0 "dest"
OpModuleProcessed "Linked by SPIR-V Tools Linker"
OpDecorate %_str Constant
OpDecorate %_str Alignment 1
OpDecorate %_str_1 Constant
OpDecorate %_str_1 Alignment 1
OpDecorate %src Alignment 4
OpDecorate %dest Alignment 4
OpDecorate %src_addr Alignment 8
OpDecorate %dest_addr Alignment 8
OpDecorate %src_0 Alignment 4
OpDecorate %dest_0 Alignment 4
%ulong = OpTypeInt 64 0
%uchar = OpTypeInt 8 0
%uint = OpTypeInt 32 0
%ulong_7 = OpConstant %ulong 7
%uchar_37 = OpConstant %uchar 37
%uchar_115 = OpConstant %uchar 115
%uchar_58 = OpConstant %uchar 58
%uchar_32 = OpConstant %uchar 32
%uchar_102 = OpConstant %uchar 102
%uchar_0 = OpConstant %uchar 0
%ulong_5 = OpConstant %ulong 5
%uchar_84 = OpConstant %uchar 84
%uchar_101 = OpConstant %uchar 101
%uchar_116 = OpConstant %uchar 116
%ulong_0 = OpConstant %ulong 0
%_arr_uchar_ulong_7 = OpTypeArray %uchar %ulong_7
%_ptr_UniformConstant__arr_uchar_ulong_7 = OpTypePointer UniformConstant %_arr_uchar_ulong_7
%_arr_uchar_ulong_5 = OpTypeArray %uchar %ulong_5
%_ptr_UniformConstant__arr_uchar_ulong_5 = OpTypePointer UniformConstant %_arr_uchar_ulong_5
%void = OpTypeVoid
%float = OpTypeFloat 32
%_ptr_CrossWorkgroup_float = OpTypePointer CrossWorkgroup %float
%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint
%40 = OpTypeFunction %void %_ptr_CrossWorkgroup_float %_ptr_CrossWorkgroup_uint
%_ptr_Function__ptr_CrossWorkgroup_float = OpTypePointer Function %_ptr_CrossWorkgroup_float
%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint
%_ptr_UniformConstant_uchar = OpTypePointer UniformConstant %uchar
%44 = OpConstantComposite %_arr_uchar_ulong_7 %uchar_37 %uchar_115 %uchar_58 %uchar_32 %uchar_37 %uchar_102 %uchar_0
%_str = OpVariable %_ptr_UniformConstant__arr_uchar_ulong_7 UniformConstant %44
%45 = OpConstantComposite %_arr_uchar_ulong_5 %uchar_84 %uchar_101 %uchar_115 %uchar_116 %uchar_0
%_str_1 = OpVariable %_ptr_UniformConstant__arr_uchar_ulong_5 UniformConstant %45
%main_test = OpFunction %void DontInline %40
%src = OpFunctionParameter %_ptr_CrossWorkgroup_float
%dest = OpFunctionParameter %_ptr_CrossWorkgroup_uint
%entry = OpLabel
%src_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_float Function
%dest_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function
OpStore %src_addr %src Aligned 8
OpStore %dest_addr %dest Aligned 8
%46 = OpLoad %_ptr_CrossWorkgroup_float %src_addr Aligned 8
%arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_float %46 %ulong_0
%47 = OpLoad %float %arrayidx Aligned 4
%48 = OpBitcast %_ptr_UniformConstant_uchar %_str
%49 = OpBitcast %_ptr_UniformConstant_uchar %_str_1
%call = OpExtInst %uint %1 printf %48 %49 %47
%50 = OpLoad %_ptr_CrossWorkgroup_uint %dest_addr Aligned 8
OpStore %50 %call Aligned 4
OpReturn
OpFunctionEnd
%2 = OpFunction %void DontInline %40
%src_0 = OpFunctionParameter %_ptr_CrossWorkgroup_float
%dest_0 = OpFunctionParameter %_ptr_CrossWorkgroup_uint
%51 = OpLabel
%52 = OpFunctionCall %void %main_test %src_0 %dest_0
OpReturn
OpFunctionEnd
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26775 >
2024-01-17 02:59:57 +00:00
Yonggang Luo
88c4de7e7b
compiler/spirv: There is not need unqualify const in function vtn_string_literal
...
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26775 >
2024-01-17 02:59:57 +00:00
Yonggang Luo
fd11818828
compiler/spirv: The spirv shader is binary, should write in binary mode
...
Fixes: 53265c8798 ("spirv: Add a mechanism for dumping failing shaders")
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26775 >
2024-01-17 02:59:57 +00:00
Konstantin Seurer
4c363acf94
vtn: Allow for OpCopyLogical with different but compatible types
...
> Result Type must not equal the type of Operand (see OpCopyObject),
> but Result Type must logically match the Operand type.
Allow for this by setting the expected type and making sure, that both
types match.
cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10163
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26252 >
2024-01-09 21:53:21 +00:00
Alyssa Rosenzweig
3da2773316
vtn: fuse OpenCL mad if we can can
...
clpeak "float" case from 1112 -> 1978 GFLOPS on rusticl on m1.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26932 >
2024-01-09 18:04:19 +00:00
Konstantin Seurer
8050b89819
vtn: Handle DepthReplacing correctly
...
The meaning of DepthReplacing was clarified in
https://gitlab.khronos.org/spirv/SPIR-V/-/issues/342 .
TLDR: It just means that the shader can write to FragDepth.
We should therefore only overwrite depth_layout if it is equal to NONE,
since NONE means "not written" and all other modes mean "written" plus
some additional information.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10344
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26876 >
2024-01-08 18:52:50 +00:00
Konstantin Seurer
4d02543853
vtn: Remove transpose(m0)*m1 fast path
...
This is broken for games that rely on invariant geometry since the usage
of matrices can affect how gl_Position is computed. The fdot fastpath
relied on if and how fdot is lowered for correctness.
Totals from 6578 (7.73% of 85071) affected shaders:
MaxWaves: 147190 -> 147170 (-0.01%)
Instrs: 4451406 -> 4438140 (-0.30%); split: -0.31%, +0.01%
CodeSize: 23553020 -> 23541772 (-0.05%); split: -0.07%, +0.03%
VGPRs: 302304 -> 302328 (+0.01%)
SpillSGPRs: 1309 -> 1329 (+1.53%)
Latency: 22509985 -> 22177164 (-1.48%); split: -1.48%, +0.00%
InvThroughput: 4862795 -> 4842951 (-0.41%); split: -0.41%, +0.01%
VClause: 85035 -> 84998 (-0.04%); split: -0.06%, +0.02%
SClause: 131008 -> 131055 (+0.04%); split: -0.02%, +0.05%
Copies: 298935 -> 298060 (-0.29%); split: -0.71%, +0.41%
PreSGPRs: 266833 -> 267292 (+0.17%); split: -0.85%, +1.03%
PreVGPRs: 249511 -> 249601 (+0.04%)
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9562
cc: mesa-stable
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26821 >
2024-01-07 22:14:36 +00:00
Caio Oliveira
0b5abf2512
spirv: Use value_id_bound to set initial memory allocated
...
Don't rely on the current default (which is 2048 bytes) buffer size for
blocks -- which ends up being too small for most shaders. Since we
already rely on value_id_bound to allocate an array of vtn_value, use
that to estimate a better value.
In addition to space for the array, we approximate the extra size of
extra data structures with the size of vtn_ssa_value, and skip it to the
next size (double it) to cover the CFG related allocations. This
results in only single system allocation necessary to back the temporary
data for the majority of the shaders.
Parsing code was slightly reordered so we can validate and read the
value_id_bound before the temporary allocator is created.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25279 >
2024-01-02 16:07:06 +00:00
Caio Oliveira
d5b4b7356e
spirv: Use linear_alloc for parsing-only data
...
All the vtn_* structures and arrays are used only during the lifetime of
spirv_to_nir(); we don't need to free them individually nor steal
them out; and some of them are smaller than the 5-pointer header
required for ralloc allocations.
These properties make them a good candidate for using an
arena-style allocation.
Change the code to create a linear_parent and use that for all the vtn_*
allocation. Note that NIR data structures still go through ralloc,
since we steal them (through the nir_shader) at the end, i.e. they
outlive the parsing.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25279 >
2024-01-02 16:07:06 +00:00
Yonggang Luo
0210b554d6
treewide: Replace the include of nir_types.h with glsl_types.h
...
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Acked-by: Caio Oliveira <caio.oliveira@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26753 >
2023-12-30 15:08:11 +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
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
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
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
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
Daniel Schürmann
f1110576d9
nir: add info.fs.require_full_quads
...
This flag indicates the requirement of helper invocations
in fragment shaders, independent from any present instructions.
This fixes the lowering of OpGroupNonUniformQuad* instructions.
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com >
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26026 >
2023-11-22 11:31:52 +01:00
Karol Herbst
924c8e7bcd
vtn: add hack for system values placed in CrossWorkgroup memory
...
Upstream bug: https://github.com/intel/llvm/issues/6703
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25701 >
2023-11-15 08:34:57 +00:00
Faith Ekstrand
dfbc03fa88
spirv: Fix locations for per-patch varyings
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998 >
2023-11-14 00:48:13 +00:00
Faith Ekstrand
4c81f87670
HACK: spirv: Add a MESA_SPIRV_DUMP_PATH environment variable
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998 >
2023-11-14 00:48:09 +00:00
Alyssa Rosenzweig
b65636ca40
nir/lower_gs_intrinsics: Count decomposed primitives too
...
We need both: decomposed primitives for transform feedback and regular
primitives for the sizing the index buffer.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Antonino Maniscalco <antonino.maniscalco@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26056 >
2023-11-07 00:05:54 +00:00
Alyssa Rosenzweig
f164edfe71
vtn: Add spirv_library_to_nir_builder feature
...
This new entrypoint takes in a SPIR-V blob and generates a header containing
a static inline nir_builder-family function for each function in the SPIR-V
library. The generated function will look for the function in the shader and, if
not found, insert a new nir_function with the appropriate signature -- to be
linked with the library later. Then, it will call the function, with the
appropriate gymnastics to handle return values as necessary.
This makes it super convenient to wrap CL libraries for use in a NIR pass.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25498 >
2023-11-02 11:37:46 +00:00
Alyssa Rosenzweig
6014f745d5
nir,vtn: Add exported bool to nir_function
...
For optimizing libraries.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25498 >
2023-11-02 11:37:46 +00:00
Karol Herbst
d6a48ff402
vtn/opencl: always lower to libclc fmod
...
The nir/spirv variant is simply not precise enough and almost everybody
lowers it anyway.
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25837 >
2023-10-27 10:52:54 +00:00
Yonggang Luo
ce5475366e
compiler,vulkan,drm-shim: Remove unused include directories from meson.build
...
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/24462 >
2023-10-27 01:35:10 +00:00
Yonggang Luo
43715516fc
treewide: Merge num_mesh_vertices_per_primitive and u_vertices_per_prim into mesa_vertices_per_prim
...
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25880 >
2023-10-26 09:35:04 +00:00
Faith Ekstrand
1a2e8290ab
nir: Add NV-specific texture opcodes
...
These are for implementing various texture queries.
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Emma Anholt <emma@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25000 >
2023-10-24 22:21:18 +00:00
Caio Oliveira
9dcc74e557
spirv: Let spirv2nir find out the shader to use
...
Previous behavior was to default to "main"/fs, this wasn't nice
when the SPIR-V module had a single shader that didn't match that spec.
New behavior is to look at the available shaders:
- if there's only one, use just use it
- if multiple, narrow down using --stage and --entry as criteria
- if still multiple after narrowing down, print the list and fail
Note you can use just one --stage or --entry if that already narrows
down to a single match. Note that in SPIR-V it is valid to have a
shader module with two shaders sharing the same entry-point name but
different stages. Because of that in rare cases both --stage and
--entry will be needed.
This patch should remove the need of using --stage and --entry for most
of the uses of spirv2nir.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25461 >
2023-10-23 22:42:45 +00:00
Caio Oliveira
c4734714ce
spirv: List entry-points in spirv2nir when unsure what to use
...
When there's ambiguity about what shader to use, list the shaders.
Conveniently print in the command line argument for, so can be copied
pasted.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25461 >
2023-10-23 22:42:45 +00:00
Caio Oliveira
45df1fd239
spirv: Change spirv2nir to use the shorter shader name abbreviations
...
This are the abbreviations we use elsewhere in Mesa. For convenience we
make them case insensitive. Old names still work for compatibility.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25461 >
2023-10-23 22:42:45 +00:00
Caio Oliveira
4d3703c12d
spirv: Expose stage enum conversion in vtn_private.h
...
Refactor it to not fail, just return MESA_SHADER_NONE. Caller
takes care of handling error. Exposed so can be used by spirv2nir
program.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25461 >
2023-10-23 22:42:45 +00:00
Marek Olšák
f3886e9c02
nir: split FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP* flags
...
GLSL doesn't preserve NaNs, but it optionally preserves Infs.
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25392 >
2023-10-17 17:27:12 +00:00
Christian Gmeiner
fe0965afa6
spirv: Don't use libclc for rotate
...
We have a nir lowering for drivers that do not support urol.
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25660 >
2023-10-11 17:39:08 +00:00
Ian Romanick
03c1e67b6c
spirv: Track when a shader has a cooperative matrix
...
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com >
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23825 >
2023-09-28 07:35:02 +00:00
Caio Oliveira
b98f87612b
spirv: Implement SPV_KHR_cooperative_matrix
...
Includes a modified version of using extract/insert for OpLoad/OpStore
from Ian.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com > (earlier version)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl > (earlier version)
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23825 >
2023-09-28 07:35:02 +00:00
Caio Oliveira
b17a2c35bc
spirv: Let vtn_ssa_value hold references to variables
...
In certain cases, we have complex opaque objects that are loaded
into (SPIR-V) SSA values. To represent these, we now can store a
reference to a variable in vtn_ssa_value.
Also implements a few operations we know will have to be supported,
like Select and Copy.
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23825 >
2023-09-28 07:35:02 +00:00
Caio Oliveira
3d7e5ec758
spirv: Expose some memory related functions in vtn_private.h
...
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com >
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23825 >
2023-09-28 07:35:02 +00:00
Caio Oliveira
3988d901ac
meson: Remove unnecessary inc_compiler mentions
...
The inc_compiler should come as part of idep_compiler, idep_nir or
idep_nir_headers dependency.
Acked-by: Eric Engestrom <eric@igalia.com >
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com > (v3dv)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25314 >
2023-09-22 14:52:50 +00:00
Caio Oliveira
ec835595f0
compiler: Use a meson dependency for libcompiler
...
That will make sure the include directories are passed on and also
make sure the generated headers are properly built before whoever code
depends on it. NIR dependency propagates that dependency too.
Since the right include directory is always propagated, we can remove
the extra "compiler/" prefix from the `#include`s in glsl_types.h.
Note: NIR has a special "header only" dependency, so include the
generated headers for compiler there too.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9843
Reviewed-by: Eric Engestrom <eric@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25314 >
2023-09-22 14:52:50 +00:00
Connor Abbott
4282386311
nir/spirv: Add inverse_ballot intrinsic
...
This is actually a no-op on AMD, so we really don't want to lower it to
something more complicated. There may be a more efficient way to do
this on Intel too. In addition, in the future we'll want to use this for
lowering boolean reduce operations, where the inverse ballot will
operate on the backend's "natural" ballot type as indicated by
options->ballot_bit_size, instead of uvec4 as produced by SPIR-V. In
total, there are now three possible lowerings we may have to perform:
- inverse_ballot with source type of uvec4 from SPIR-V to inverse_ballot
with natural source type, when the backend supports inverse_ballot
natively.
- inverse_ballot with source type of uvec4 from SPIR-V to arithmetic,
when the backend doesn't support inverse_ballot.
- inverse_ballot with natural source type from reduce operation, when
the backend doesn't support inverse_ballot.
Previously we just did the second lowering unconditionally in vtn, but
it's just a combination of the first and third. We add support here for
the first and third lowerings in nir_lower_subgroups, instead of simply
moving the second lowering, to avoid unnecessary churn.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25123 >
2023-09-20 14:41:18 +00:00
Dave Airlie
f423d91790
spirv: use a pointer sized int type for opencl event_t
...
llvm16 + opaque pointers uses a ptr to event for the opaque type,
llvm 17 fixes this properly, but the fix doesn't look too backportable.
Cc: mesa-stable
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25165 >
2023-09-13 00:22:51 +00:00
Dave Airlie
f5bf4657fb
nir: add driver_functions option to avoid inlining.
...
This adds a driver control to instruct NIR to not inline
all functions.
It adds a very simple inlining heuristic that works for
what I've played with, but will probably need to grow some
better ideas.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24687 >
2023-09-12 01:57:50 +00:00
Dave Airlie
8a95b43880
spirv/nir: parse function control and store in nir.
...
This just lets the nir access the inline/dont inline attributes
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24687 >
2023-09-12 01:57:50 +00:00
Alyssa Rosenzweig
25cc04c59b
treewide: Use nir_before/after_impl in easy cases
...
These open-code the same idiom as the helper.
Via Coccinelle patch:
@@
expression func_impl;
@@
-nir_before_cf_list(&func_impl->body)
+nir_before_impl(func_impl)
@@
expression func_impl;
@@
-nir_after_cf_list(&func_impl->body)
+nir_after_impl(func_impl)
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24910 >
2023-08-30 19:30:58 +00:00
norablackcat
25bc3d2824
spirv/nir_to_spirv: add expect assume op codes
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23115 >
2023-08-22 17:28:05 +00:00
Konstantin Seurer
2489f7d84f
spirv: Implement SPV_AMDX_shader_enqueue
...
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24512 >
2023-08-18 16:57:22 +00:00
Konstantin Seurer
289df72d10
spirv: Update headers and grammer JSON
...
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24512 >
2023-08-18 16:57:22 +00:00
Jason Ekstrand
f34f740b64
spirv: Re-emit constants at their uses
...
Right now, spirv_to_nir places all constants at the top of the function
and has a hash table to de-duplicate them. This change drops the hash
table and starts re-emitting constants more-or-less at their uses. This
is more consistent with what we do in GLSL -> NIR translation. It is,
however, a change to SPIR-V -> NIR translation which will likely affect
other optimizations in unexpected ways so it should be evaluated
separately.
This gives some good saves for spills/fills for Intel, without causing
any significant regressions on RADV, because it is using the
nir_opt_reuse_constants() pass. In the long run that should be superseded
by some form of GCM.
```
Intel TGL results for Intel fossils:
Totals:
Instrs: 183287977 -> 183269431 (-0.01%); split: -0.07%, +0.06%
Cycles: 18224600804 -> 18223114114 (-0.01%); split: -0.16%, +0.15%
Spill count: 111031 -> 108377 (-2.39%); split: -2.45%, +0.06%
Fill count: 221781 -> 216479 (-2.39%); split: -2.39%, +0.00%
Scratch Memory Size: 4355072 -> 4180992 (-4.00%); split: -5.31%, +1.32%
Totals from 43684 (6.54% of 667704) affected shaders:
Instrs: 38289482 -> 38270936 (-0.05%); split: -0.33%, +0.28%
Cycles: 7166415272 -> 7164928582 (-0.02%); split: -0.40%, +0.38%
Spill count: 93747 -> 91093 (-2.83%); split: -2.90%, +0.07%
Fill count: 190943 -> 185641 (-2.78%); split: -2.78%, +0.00%
Scratch Memory Size: 3127296 -> 2953216 (-5.57%); split: -7.40%, +1.83%
```
```
RADV GFX1100 results for radv fossils:
Totals:
Instrs: 71623708 -> 71624667 (+0.00%); split: -0.00%, +0.01%
CodeSize: 369324312 -> 369334744 (+0.00%); split: -0.00%, +0.01%
SpillSGPRs: 13586 -> 13582 (-0.03%)
SpillVGPRs: 911 -> 910 (-0.11%); split: -0.55%, +0.44%
Latency: 632887831 -> 632880378 (-0.00%); split: -0.00%, +0.00%
InvThroughput: 81674859 -> 81676684 (+0.00%); split: -0.00%, +0.01%
VClause: 1273752 -> 1273727 (-0.00%); split: -0.00%, +0.00%
SClause: 2409593 -> 2409078 (-0.02%); split: -0.02%, +0.00%
Copies: 4063579 -> 4064425 (+0.02%); split: -0.05%, +0.07%
Branches: 1196723 -> 1196720 (-0.00%); split: -0.00%, +0.00%
Totals from 16244 (12.17% of 133461) affected shaders:
Instrs: 31116807 -> 31117766 (+0.00%); split: -0.01%, +0.01%
CodeSize: 160316656 -> 160327088 (+0.01%); split: -0.01%, +0.01%
SpillSGPRs: 12270 -> 12266 (-0.03%)
SpillVGPRs: 835 -> 834 (-0.12%); split: -0.60%, +0.48%
Latency: 344388549 -> 344381096 (-0.00%); split: -0.01%, +0.00%
InvThroughput: 43043761 -> 43045586 (+0.00%); split: -0.01%, +0.01%
VClause: 433221 -> 433196 (-0.01%); split: -0.01%, +0.00%
SClause: 900825 -> 900310 (-0.06%); split: -0.06%, +0.00%
Copies: 1989000 -> 1989846 (+0.04%); split: -0.11%, +0.15%
Branches: 676625 -> 676622 (-0.00%); split: -0.00%, +0.00%
```
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5282 >
2023-08-17 14:58:02 +00:00
Faith Ekstrand
b781dd6200
nir s/nir_get_ssa_scalar/nir_get_scalar/
...
Generated with sed:
sed -i -e 's/nir_get_ssa_scalar/nir_get_scalar/g' src/**/*.h src/**/*.c src/**/*.cpp
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24703 >
2023-08-15 17:44:27 +00:00
Faith Ekstrand
4695bebc79
nir: Drop nir_dest
...
Instead, we replace every use of it with nir_def. Most of this commit
was generated by sed:
sed -i -e 's/dest.ssa/def/g' src/**/*.h src/**/*.c src/**/*.cpp
A few manual fixups were required in lima and the nir_legacy code.
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24674 >
2023-08-14 21:22:53 +00:00