Commit Graph

191 Commits

Author SHA1 Message Date
Ian Romanick 45b0d0817f nir: Add missing dependency on nir_opcodes.py
Commit 38800b38 changed nir_opcodes.py, but that doesn't seem to have
triggered nir_opt_algebraic.py.  The change in 75ef5991 depends on
opt_algebraic lowering 16-bit versions of slt, but if opt_algebraic is
not rebuilt, this may not happen.  This resulted in some people seeing
assertion failures in, for example,
dEQP-VK.spirv_assembly.instruction.compute.float16.arithmetic_3.step,
due to the backend seeing nir_op_slt that it didn't know how to handle.

v2: Add nir_opcodes.py to nir_algebraic_py so that all the per-driver
algebraic passes pick up the dependency too.  Rename it to
nir_algebraic_depends.  Suggested by Emma.

Closes: #6047
Fixes: d1992255bb ("meson: Add build Intel "anv" vulkan driver")
Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15050>
(cherry picked from commit a01b262990)
2022-02-23 17:55:56 +00:00
Boris Brezillon a1c1a60630 microsoft/compiler: Fix dxil_nir_create_bare_samplers()
_mesa_hash_table_u64_search() returns the data directly, not an
hash_entry object.

Fixes: 46bc7cf678 ("microsoft/compiler: Rewrite sampler splitting pass to be smarter and handle derefs")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
(cherry picked from commit 83280b8e23)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14377>
2022-01-12 19:54:24 +00:00
Jesse Natalie 507ec26688 microsoft/compiler: Implement inot
Fixes: cb283616 ("nir/algebraic: Small optimizations for SpvOpFOrdNotEqual and SpvOpFUnordEqual")
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14140>
(cherry picked from commit 45354be410)
2021-12-29 20:56:29 +00:00
Michael Tang 25b007d7a9 microsoft/spirv_to_dxil: turn sysvals into input varyings
Fixes: b47090c5b3 ("spirv: Always declare FragCoord as a sysval")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13276>
(cherry picked from commit 3094524621)
2021-10-27 19:58:10 +01:00
Michael Tang c0e45dd882 microsoft/spirv_to_dxil: use dxil_nir_lower_bool_input pass
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13262>
2021-10-08 17:21:33 +00:00
Michael Tang 36aa1a2959 gallium/d3d12: move d3d12_lower_bool_input to microsoft/compiler
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13262>
2021-10-08 17:21:33 +00:00
Enrico Galli c79ec5ea3c nir_to_dxil: Add tagging raw SRVs in shader flags
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13157>
2021-10-05 23:32:18 +00:00
Lionel Landwerlin 3c8c817ae7 clc: add allowed extension for compile parameter
The LLVM-SPIRV translator can include a bunch of capabilities into the
generated SPIRV which is not what you always want. That include
internal Intel specific capabilities from the translator.

v2: Rename options
    Fixup checks (Jesse)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13113>
2021-10-03 19:32:54 +00:00
Jason Ekstrand 1506ea2ecb Move a bunch of the CLC stuff from src/microsoft to common code
The D3D12-specific stuff isn't useful to have in common code but all the
stuff to invoke clang really should be common.

v2: Rebase (Lionel)

v3: Define a new clc_libclc_new_dxil() entrypoint to create a clc
    context with DXIL nir_options (Jesse)

v4: Fixup meson build (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>
2021-09-30 07:09:08 +00:00
Lionel Landwerlin a9c49a0541 meson: extract libversion checks from clc & clover
The src/microsoft/clc/meson.build was assuming to be run only on
Windows. That's about to change.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>
2021-09-30 07:09:08 +00:00
Lionel Landwerlin 2bc4650b45 microsoft/clc: fix compiler warning on uninitiailzed variable use
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>
2021-09-30 07:09:08 +00:00
Lionel Landwerlin 1d7a5196b1 microsoft/clc: drop MSVC specific function
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>
2021-09-30 07:09:08 +00:00
Lionel Landwerlin 32358b0335 microsoft/clc: drop LLVM dependency to version < 12
Prior to LLVM 12, SmallVector requires 2 template arguments.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: c4755a7c32 ("microsoft/clc: Support SPIR intermediates in the compilation APIs")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13083>
2021-09-28 13:29:56 +00:00
Lionel Landwerlin 1c92d355c6 clc: use the defined version for the parser
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13018>
2021-09-24 12:33:19 +00:00
Lionel Landwerlin dce8870f64 microsoft/clc: small compile fix on Linux
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13018>
2021-09-24 12:33:19 +00:00
Jesse Natalie 7aa060ec38 microsoft/clc: Add a test for specializing via SPIRV-Tools
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie 068c6b5a37 microsoft/clc: Add API to independently specialize SPIR-V
We need the ability to specialize unlinked SPIR-V, so use SPIR-V tools
to specialize prior to linking.

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie c50bbf1f28 microsoft/clc: Support passing specialization consts to spirv_to_nir
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie a699844ffb microsoft/clc: Parse SPIR-V specialization consts into metadata
We need to be able to validate at the API that set specialization consts
have a valid ID and the value is the correct size.

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie c4755a7c32 microsoft/clc: Support SPIR intermediates in the compilation APIs
We can now export SPIR (mainly just for testing) or import SPIR and
convert to SPIR-V.

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie 91e08312d8 microsoft/clc: Split clc_object and rename entrypoints
clc_object was overloaded, containing SPIR-V binary and metadata,
and it would only sometimes contain metadata (after linking). Split
it into a more generic clc_binary class which holds some type of data
(the kind depends on where it came from), and clc_metadata which can
be independently parsed on compiled or linked data.

Rename a couple entrypoints to be more explicit about what they're
actually transforming (c_to_spirv, link_spirv, spirv_to_dxil).

Add a logger to SPIR-V binary parsing so it can report errors on app-
provided SPIR-V.

Re-order helper function parameters to be more consistent (out params last).

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie c3666eec7e microsoft/clc: Stop heap-allocating tiny fixed-size transparent structs
The caller can allocate these however they want. They don't need
independent allocations. Removes some unnecessary failure handling.

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie 27467700e9 microsoft/clc: Clean up clc_context
1. Rename it to libclc to match what it is
2. Make it opaque externally
3. Remove it from non-essential entrypoints (compile/link)

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Jesse Natalie 24b096035f microsoft/clc: Rename compiler DLL to clon12compiler
I no longer think there's value in trying to share code on disk here between
CL and GL at runtime, especially since we're now just building GL without LLVM

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
2021-09-23 13:06:41 +00:00
Emma Anholt aed4c0b5a9 nir: Drop the unused instr arg for src/dest copy functions.
Now that we don't use ralloc, we don't need this arg to get at the right
ralloc ctx.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11776>
2021-09-14 17:53:06 +00:00
Michael Tang f7e575ce0d microsoft/spirv_to_dxil: Add `install : true` to spirv_to_dxil library.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12758>
2021-09-08 00:00:42 +00:00
Jesse Natalie 015cc73407 spirv2dxil: Fix build after spirv_to_dxil signature change
Fixes: ada05759 ("spirv_to_dxil: Convert out parameters to a single object")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5322
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12728>
2021-09-04 19:47:41 -07:00
Enrico Galli 398d591b65 spirv_to_dxil: Add support for non-zero vertex and instance indices
Since DXIL does not have a way to get the base/first vertex and base
instance as well as using a zero-based vertex index, these values need
to be passed in via a constant buffer.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12707>
2021-09-03 16:21:03 +00:00
Enrico Galli 49ef896a5e spirv_to_dxil: Add support for nir_intrinsic_load_num_workgroups
Since DXIL does not have a way to get the number of workgroups used
during dispatch with a system-value, these numbers need to be passed in
via a constant buffer.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12707>
2021-09-03 16:21:03 +00:00
Enrico Galli ada05759e1 spirv_to_dxil: Convert out parameters to a single object
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12707>
2021-09-03 16:21:03 +00:00
Rhys Perry ae00f5af61 nir: separate lower_add_sat
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12617>
2021-09-03 13:21:27 +00:00
Erik Faye-Lund c8581d0fae microsoft/compiler: trivial fixes to error-handling
We're really bad at making sure we report errors when we fail to
allocate memory. This makes us a bit better...

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12541>
2021-08-26 18:57:40 +00:00
Erik Faye-Lund e0f3133447 microsoft/compiler: return errors from get_n_src
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12541>
2021-08-26 18:57:40 +00:00
Erik Faye-Lund 2c166a27fc microsoft/compiler: remove needless error-returns
There's no root error-conditions in this code, just code that assumes
they exist and tries to handle them.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12541>
2021-08-26 18:57:40 +00:00
Michael Tang 4a3395f35a microsoft/compiler: Miscellaneous fixes from running clang-format
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12513>
2021-08-25 20:19:05 +00:00
Michael Tang 1aca20be14 microsoft/compiler: Emit a flat interpolation method for SV_SampleIndex
We do not want to set an interpolation method for vertex shader inputs.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12513>
2021-08-25 20:19:05 +00:00
Michael Tang 74a24f4f1c microsoft/compiler: Set the SampleFrequency runtime metadata
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12513>
2021-08-25 20:19:05 +00:00
Michael Tang 88220083cf microsoft/compiler: More robustly handle setting Register=-1
This is the 'N/A mask' case in the DXIL disassembly.

This logic is taken from: 7c9e487afd/tools/clang/tools/dxcompiler/dxcdisassembler.cpp (L106)

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12513>
2021-08-25 20:19:05 +00:00
Michael Tang 62c3492d0b microsoft/compiler: Add support for SV_SampleIndex intrinsic
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12513>
2021-08-25 20:19:05 +00:00
Michael Tang 4237aa3a7e spirv_to_dxil: Run nir_lower_tex during compilation
We need this to get e.g. a default lod for some instructions when it is
not provided.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12462>
2021-08-24 22:18:30 +00:00
Emma Anholt 673cc9323a nir: Move phi src setup to a helper.
Cleans up the ralloc/list push code all over the tree.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11772>
2021-08-13 16:11:57 +00:00
Marcin Ślusarz 65f9234f96 microsoft/compiler: use nir_shader_instructions_pass in dxil_nir_lower_double_math
No functional changes.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
2021-08-11 11:23:30 +00:00
Marcin Ślusarz b8de41902e microsoft/compiler: use nir_shader_instructions_pass in dxil_nir_split_clip_cull_distance
No functional changes.

v2: fix build

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
2021-08-11 11:23:30 +00:00
Marcin Ślusarz 9aafb91f0e microsoft/compiler: preserve all metadata when upcast_phi doesn't make progress
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
2021-08-11 11:23:30 +00:00
Marcin Ślusarz 17a61ec541 microsoft/clc: use nir_shader_instructions_pass in clc_nir_dedupe_const_samplers
Changes:
- nir_metadata_preserve(..., nir_metadata_all) is called when pass doesn't
  make progress

v2: fix build

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
2021-08-11 11:23:30 +00:00
Marcin Ślusarz 70723f278f microsoft/clc: preserve only valid metadata in clc_lower_printf_base
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
2021-08-11 11:23:30 +00:00
Vinson Lee 87efa1ee22 spirv_to_dxil: Fix missing-prototypes build error.
../src/microsoft/spirv_to_dxil/spirv_to_dxil.c: At top level:
../src/microsoft/spirv_to_dxil/spirv_to_dxil.c:200:1: error: no previous prototype for ‘spirv_to_dxil_get_version’ [-Werror=missing-prototypes]
  200 | spirv_to_dxil_get_version()
      | ^~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 92b0cf8e77 ("spirv_to_dxil: expose version number")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12264>
2021-08-07 11:11:31 -07:00
Enrico Galli cc8a122907 microsoft/compiler: Add support for local_invocation_index
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12228>
2021-08-05 23:54:26 +00:00
Enrico Galli f9f3713c84 microsoft/spirv_to_dxil: Enable support for shared memory
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12228>
2021-08-05 23:54:26 +00:00
Michael Tang 92b0cf8e77 spirv_to_dxil: expose version number
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12227>
2021-08-05 13:30:42 -07:00