Commit Graph

659 Commits

Author SHA1 Message Date
Jesse Natalie 8d5b7450a4 microsoft/compiler: Delete non-sysval deref load/store code
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14175>
2021-12-20 08:20:55 -08:00
Jesse Natalie f30768f1d6 microsoft/compiler: Lower io
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14175>
2021-12-20 08:20:52 -08:00
Jesse Natalie f4d247c2e3 microsoft/compiler: Support lowered io (nir_intrinsic_load_input/store_output)
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14175>
2021-12-20 08:20:11 -08:00
Caio Oliveira 3415b51b1c ci/windows: Remove line numbers of SPIR-V errors in spirv2dxil tests
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14245>
2021-12-17 23:04:55 +00:00
Jesse Natalie 46ef1e8389 ci/windows: Remove line numbers from assertions in spirv2dxil tests
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14156>
2021-12-11 03:43:11 +00:00
Jesse Natalie 11eb03c44e microsoft/compiler: Remove algebaric pass for inot
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>
2021-12-10 23:23:29 +00:00
Jesse Natalie 45354be410 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>
2021-12-10 23:23:29 +00:00
Lionel Landwerlin 4c703686db spirv: handle ray query intrinsics
v2: Fixup comment (Caio)
    Use generated builders (Caio)

v3: Update spirv2dxil CI expectations

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13718>
2021-12-04 20:46:35 +00:00
Jesse Natalie 7afb4aba3f CI/windows: Move reference files to relevant ci subdirectories
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13902>
2021-12-01 18:26:15 +00:00
Jesse Natalie c70e31c4d5 CI/windows: Move SPIRV-to-DXIL test YML to microsoft folder
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13902>
2021-12-01 18:26:15 +00:00
Boris Brezillon 83280b8e23 microsoft/compiler: Fix dxil_nir_create_bare_samplers()
_mesa_hash_table_u64_search() returns the data directly, not an
hash_entry object. We also need to take the descriptor set into account
for this pass to work properly on Vulkan shaders.

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>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13912>
2021-12-01 08:51:05 +01:00
Jesse Natalie 5bfbf4bec9 microsoft/compiler: Handle GLES external textures
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13054>
2021-11-19 22:54:46 +00:00
Jesse Natalie f0e5bc228c microsoft/clc: Add a test for arg metadata
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13759>
2021-11-15 07:47:06 -08:00
Vinson Lee 1ca90f8752 microsoft/spirv_to_dxil: Fix non-Windows build.
../src/microsoft/spirv_to_dxil/dxil_validation.cpp: In function ‘bool validate_dxil(dxil_spirv_object*)’:
../src/microsoft/spirv_to_dxil/dxil_validation.cpp:129:12: error: ‘stderr’ was not declared in this scope
  129 |    fprintf(stderr, "DXIL validation only available in Windows.\n");
      |            ^~~~~~

Fixes: 37c366e283 ("microsoft/spirv_to_dxil: Add DXIL validation to spirv2dxil")
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/13736>
2021-11-11 01:37:16 +00:00
Enrico Galli 37c366e283 microsoft/spirv_to_dxil: Add DXIL validation to spirv2dxil
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13655>
2021-11-09 01:32:47 +00:00
Jesse Natalie 8d3a3e7a00 microsoft/compiler: Use textures for SRVs
After running the (renamed) dxil_nir_split_typed_samplers pass, the
shader will have either:
* Textures, which map to D3D SRVs
* Bare samplers, which map to D3D bare samplers
* Images, which map to D3D UAVs

There shouldn't be any remaining samplers with type information

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13390>
2021-11-02 11:02:22 -07:00
Michael Tang 7e26ea84da microsoft/compiler: Use memcpy instead of a union to write dxil_features
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13496>
2021-10-26 20:27:56 +00:00
Michael Tang 3094524621 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>
2021-10-26 16:18:09 +00:00
Jason Ekstrand 956199e870 nir: s/nir_var_mem_image/nir_var_image/g
We typically use nir_var_mem_* for stuff that has an explicit byte-based
memory layout.  Images are opaque.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13386>
2021-10-16 03:47:10 +00:00
Dylan Baker e73096bd6d meson: use gtest protocol for gtest based tests when possible
With the `gtest` protocol meson will add some extra arguments to the
test to generate better junit results, which may be useful. This
protocol is only available in meson 0.55.0+, so keep using the default
`exitcode` protocol for meson older than that.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8484>
2021-10-16 03:22:24 +00:00
Enrico Galli aac47c4b24 microsoft/compiler: Shadow tex instructions always use shadow samplers
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13321>
2021-10-16 00:12:04 +00:00
Jesse Natalie 9601556079 microsoft/clc: Images use nir_var_mem_image
The only big change is that lower_vars_to_explicit no longer assigns
a driver_location for images. That means that the storage for the
format/order loads is no longer implicitly "allocated" in the middle
of the kernel args. Instead, manually add the storage for that to the end
of the input args buffer.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4743>
2021-10-15 14:58:56 +00: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
Erik Faye-Lund d762a01e18 microsoft/compiler: harmonize num_psv_inputs with outputs
This doesn't seems to make a practical difference, but it seems better
to do it the same way as we do for outputs, as well as what DXC does.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12197>
2021-08-05 09:17:40 +00:00
Erik Faye-Lund 63dae1bd8b microsoft/compiler: fix psv-output calculation
Rather surprisingly, the value stored in the NumVectors field of the
DXIL PSV header isn't the number of vectors, but rather the *maximum*
vector used.

This makes a difference when we're not writing to the first element of
an array, where we would previously generate a validation error.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12197>
2021-08-05 09:17:40 +00:00
Jesse Natalie 4c5f1ef3ca microsoft/clc: Add a test for compiling a kernel with a read-write image
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10163>
2021-07-29 14:54:48 -07:00
Jesse Natalie 6126dd29a4 microsoft/compiler: Implement texture loads from UAVs
This comes to the backend as image_load rather than txf but the
DXIL intrinsic is the same at the end of the day.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10163>
2021-07-29 14:54:31 -07:00
Enrico Galli fec1a04c53 microsoft/compiler: Correctly flag when using raw buffers
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12119>
2021-07-29 01:44:45 +00:00
Enrico Galli 1295c5cb33 microsoft/compiler: Add support for arrays to image_store
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12119>
2021-07-29 01:44:45 +00:00
Enrico Galli 73262d4bd4 microsoft/spirv_to_dxil: Adding continue opt pass to fix DXIL loop gen
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12048>
2021-07-24 14:47:41 +00:00
Erik Faye-Lund e212a191a6 dxil: Set coord_components on the txf in lower_int_sampler
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11775>
2021-07-23 15:53:57 +00:00
Jason Ekstrand 624e799cc3 nir: Drop nir_ssa_def::name and nir_register::name
We say that they're for debug only but we don't really have a good
policy around when to set them and when not to.  In particular,
nir_lower_system_values and nir_lower_vars_to_ssa which are the chief
producers of SSA values which might reasonably have a name do not bother
to set one.  We have some names set from things like BLORP and RADV's
meta shaders but AFAICT, they're setting a name more because it's there
than because they actually care.

Also, most things other than nir_clone and nir_serialize don't bother to
try and preserve them.  You can see in the diffstat of this commit
exactly what passes attempt to preserve names.  Notably missing from the
list is opt_algebraic which is the single largest source of SSA def
churn and it happily throws names away.

These observations lead me to question whether or not names are actually
useful at all or if they're just taking up space (8B per instruction)
and wasting CPU cycles (to ralloc_strdup on the off chance we do have
one).  I don't think I can think of a single time in recent history
where I've been debugging a shader issue and a SSA value name has been
there and been useful.  If anything, the few times they are there, they
just throw me off because they mess up the indentation in nir_print.

iris shader-db on my system gets runtime -2.07734% +/- 1.26933% (n=5)

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5439>
2021-07-08 17:34:41 +00:00
Jesse Natalie 02efc5a099 microsoft/compiler: Change behavior for emitting inexpressible barriers
If the barrier tries to apply to memory that we can't express, just
don't apply the memory portion of the barrier. Similarly, if it tries
to apply a global memory barrier at invocation level, upgrade it to
thread-group.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11670>
2021-07-01 21:05:14 +00:00
Enrico Galli ddad83fc97 microsoft/compiler: Add support for get_ssbo_size to translator
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11629>
2021-06-29 23:15:28 +00:00
Enrico Galli d0cbd39a5c microsoft/spirv_to_dxil: Add drive_location assignment
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10989>
2021-06-24 20:05:13 +00:00
Enrico Galli aa7aa7c78f microsoft/compiler: Switch io sort to use nir_sort_variables_with_modes
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10989>
2021-06-24 20:05:13 +00:00
Enrico Galli e2e22720dc d3d12, microsoft/compiler: Moving driver_location allocation to compiler
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10989>
2021-06-24 20:05:12 +00:00
Enrico Galli d0f1698a73 d3d12, microsoft/compiler: Switching semantic names to TEXCOORD
Switching from GENERIC/VARYING to TEXCOORD. This change better aligns
with other dxil generators (SPIRV-Cross, Tint).

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10989>
2021-06-24 20:05:12 +00:00
Enrico Galli b8e2374950 microsoft/compiler: Remove de-duplication of arbitrary semantic names
Since DXC doesn't perform de-duplication for arbitrary semantic names,
and the DXIL validator checks against this behavior. We need to remove
the de-duplication.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10989>
2021-06-24 20:05:12 +00:00
Caio Marcelo de Oliveira Filho 8af6766062 nir: Move workgroup_size and workgroup_variable_size into common shader_info
Move it out the "cs" sub-struct, since these will be used for other
shader stages in the future.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11225>
2021-06-08 09:23:55 -07:00
Rhys Perry 1cbcfb8b38 nir, nir/algebraic: add byte/word insertion instructions
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3151>
2021-06-08 08:57:42 +00:00
Caio Marcelo de Oliveira Filho c8a7bd0dc8 nir: Rename WORK_GROUP (and similar) to WORKGROUP
Be consistent with other usages in Vulkan and SPIR-V, and the recently
added workgroup_size field.

Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11190>
2021-06-07 22:34:42 +00:00
Caio Marcelo de Oliveira Filho a71a780598 nir: Rename nir_intrinsic_load_local_group_size to nir_intrinsic_load_workgroup_size
Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11190>
2021-06-07 22:34:42 +00:00
Caio Marcelo de Oliveira Filho 430d2206da compiler: Rename local_size to workgroup_size
Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11190>
2021-06-07 22:34:42 +00:00
Michael Tang 58f843a193 microsoft/compiler: Maintain sorting of resource type in the context
This change moves the SRVs associated with read-only SSBOs to be emitted
before any other UAV. We do this because the validator expects resources
to be emitted in a specific order, as noted by `emit_module`.

Previously, we emitted SSBOs as SRVs (read-only) or UAVs (read-write)
after other UAVs.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10514>
2021-04-29 23:55:02 +00:00
Juan A. Suarez Romero e532a47f76 util/hash_table: do not leak u64 struct key
For non 64bit devices the key stored in hash_table_u64 is wrapped in
hash_key_u64 structure, which is never free.

This commit fixes this issue by just removing the user-defined
`delete_function` parameter in hash_table_u64_{destroy,clear} (which
nobody is using) and using instead a delete function to free this
structure.

Fixes: 608257cf82 ("i965: Fix INTEL_DEBUG=bat")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10480>
2021-04-29 12:58:23 +02:00
Jesse Natalie 29ad039d13 microsoft/compiler: Handle unbounded arrays
Note that it's no longer sufficient to check for >=1 sampler/image
in a potential array, because unbounded arrays have 0 of them.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10298>
2021-04-27 23:13:19 +00:00
Jesse Natalie 611934c556 microsoft/compiler: Map descriptor set -> binding space
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10298>
2021-04-27 23:13:19 +00:00
Jesse Natalie c218f4a56e microsoft/compiler: Fix function signature for bufferStore to support overloads
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10298>
2021-04-27 23:13:19 +00:00
Jesse Natalie 46bc7cf678 microsoft/compiler: Rewrite sampler splitting pass to be smarter and handle derefs
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10298>
2021-04-27 23:13:19 +00:00
Jesse Natalie ec9fa0ed13 d3d12, microsoft/compiler: Use SRV/sampler variable binding data
For GL, we've previously mostly ignored the binding property for sampler variables
during the shader compilation step. For CL, our image bindings were always 0-based as well.

Now, for Vulkan, we are going to be getting explicit bindings and need to emit DXIL that
respects those bindings. Since Vulkan can also have both split and combined images and samplers,
we now need to be smarter about recognizing when NIR is trying to use a "sampler" as *both* an
image and sampler (in deref mode, the same variable will be deref'd as both image and sampler).

That "being smarter" bit comes next, but first, let's prep GL for building correct root
signatures and binding the resources correctly.

Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10298>
2021-04-27 23:13:19 +00:00
Enrico Galli 3a3ab2f8ee microsoft/compiler: zero out unused WebGPU system values
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10439>
2021-04-27 01:53:16 +00:00
Jesse Natalie 7e905bd00f microsoft/spirv_to_dxil: Treat read-only storage images as SRVs
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10356>
2021-04-23 23:16:15 +00:00
Jesse Natalie 05d90ed9da microsoft/compiler: Treat read-only SSBOs as SRVs
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10356>
2021-04-23 23:16:15 +00:00
Jesse Natalie fa677c8644 nir_lower_readonly_images_to_tex: Support non-CL semantics
For non-CL, intrinsic access isn't set, because the image type doesn't
have access qualifier. Instead, the access qualifier is set on the variable.

So, add a mode to this pass which can chase back to the variable in addition
to the intrinsic access. Also, update the variable type and the deref chain
types so everything is consistent, that the tex is accessing a sampler. Note
we can't do this for CL, because void-typed samplers don't exist.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10356>
2021-04-23 23:16:15 +00:00
Jesse Natalie 29c9731400 nir: Rename nir_lower_cl_images_to_tex, replace 'cl' with 'readonly'
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10356>
2021-04-23 23:16:15 +00:00
Jesse Natalie 53c97f92cd microsoft/compiler: For Vulkan environment, don't create resource handles upfront
Creating resource handles upfront works well while we have fixed-size resource
counts, but once we start talking about bindless, having arrays or even sets
of handles becomes prohibitive. It also precludes dynamic indexing for textures.

Instead, rely on the load_vulkan_descriptor instruction for UBO/SSBO, and undo
nir_lower_samplers so we continue to have deref chains for image/sampler accesses.
Then, emit handles at the end of a deref chain - the chain should only have
array offsets, so once we get to a type that's not an array anymore, we can
emit the handle.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10288>
2021-04-22 02:43:30 +00:00
Jesse Natalie f6667b13f2 microsoft/compiler: Remove assert-only resource size or usage tracking
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10288>
2021-04-22 02:43:30 +00:00
Jesse Natalie 86e443d0cc microsoft/compiler: Remove hardcoded limits on numbers of resource arrays
While GL and CL might have limits here, Vulkan doesn't, and can declare
tons of individual variables.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10288>
2021-04-22 02:43:30 +00:00
Jesse Natalie 67b5fba62a microsoft/compiler: Fix MSVC warning C4334 (32bit shift cast to 64bit)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Cc: mesa-stable@lists.freedesktop.org
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10331>
2021-04-20 00:28:35 +00:00
Jesse Natalie 53786d2eb2 microsoft/clc: Fix undeclared function warning
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Cc: mesa-stable@lists.freedesktop.org
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10331>
2021-04-20 00:28:34 +00:00
Jesse Natalie d641adca6a microsoft/clc: Fix MSVC unreferenced variable warnings
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Cc: mesa-stable@lists.freedesktop.org
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10331>
2021-04-20 00:28:34 +00:00
Jesse Natalie 8c140006e2 microsoft/clc: If local size isn't specified either in the shader or at runtime, set it to (1,1,1)
Otherwise we can end up in situations like having divide-by-zero. If the optimization is smart enough
that we end up with a *constant* divide-by-zero, then the DXIL validator will fail to sign, which
can trigger fatal errors with CLOn12.

We want to run an initial translation of all kernels during program build, but at that point we don't
know the local size to be able to specify it through kernel specialization data.

v2: Metadata output of 0 is used to indicate that the size wasn't explicitly specific. Copy the
    size to the metadata before overriding it to (1,1,1). If conf was explicitly specified,
    update the metadata again (though nobody should be paying attention to it).

Closes: https://github.com/microsoft/OpenCLOn12/issues/20
Closes: https://github.com/darktable-org/darktable/issues/8700
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10303>
2021-04-19 15:38:57 +00:00
Jesse Natalie aea6f8effc microsoft/compiler: Propagate access when lowering SSBO loads
We'll want to preserve whether the load is accessing a read-only
SSBO or not.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 474824bf3d microsoft/compiler: Support raw SRVs in addition to typed SRVs
These will be used for read-only SSBOs

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie a5f402f002 microsoft/compiler: Store nir_shader in the ntd_context
This means we can stop passing it as a second parameter all the time

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 50d7e97c1d microsoft/compiler: Better support UBO/SSBO references to descriptors
Previously UBOs only supported static indices, and SSBOs only
supported dynamic indices. UBO support for descriptors was added
as an alternative to static indices, but the logic for detecting
descriptors to SSBOs couldn't just differentiate on constants vs not.

Add a helper which can differentiate cleanly across the board and
handle pre-created handles from descriptors, or static/dynamic raw
indices.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie d6b5aaaff8 microsoft/compiler: Split Vulkan resource_index / descriptor processing
Instead of doing all of the handle logic in the descriptor load, split
it so that the resource index is actually computed during resource_index
processing, and it's converted to a handle during the load_descriptor.

At the same time, add SSBO handling and dynamic indexing handling.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 8a821e2b8b microsoft/compiler: Emit SSBO variables
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 15de712270 microsoft/compiler: Emit CBVs via variables for Vulkan
The resources need to be emitted in a particular order, so CBVs
have to be emitted first and can't be emitted as we iterate through
instructions.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie debdc81ccf microsoft/compiler: Support arrays of UBOs
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 88ff88bb7d microsoft/compiler: Support raw SRVs/UAVs through dxil_module_get_res_type
Switch the OpenCL "globals" array to use that helper

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 0c8220685e microsoft/spirv_to_dxil: Lower loads/stores to DXIL
This adjusts UBO loads to be float4 loads, and handles SSBO accesses
that are larger/smaller than 32bit.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 14997c7e96 microsoft/spirv_to_dxil: Lower samplers from deref to index
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
2021-04-16 17:08:17 +00:00
Jesse Natalie 8cc3100226 microsoft/clc: Update unit test to always use COMMON state for buffers
New Windows versions have new debug validation warning that for resources that
aren't actually UPLOAD/READBACK (which these aren't, thanks to the
GetCustomHeapProperties call), initial state that's not COMMON doesn't actually
do anything, which causes these tests to all fail because they verify that
they don't produce debug layer messages.

Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10190>
2021-04-12 18:50:20 +00:00
Lionel Landwerlin ec6d9b7fb2 microsoft: fixup clc_log() define
The local msg variable shadows one of the argument of
SPIRVMessageConsumer making the error message "(null)".

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/10133>
2021-04-09 15:29:39 +03:00
Jesse Natalie 34c84b6f0e microsoft/compiler: Add some more float16 support
We can support float16 constants, b2f16, and casts to float16.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Jesse Natalie ca08e74525 microsoft/spirv_to_dxil: Support doubles
First, we need to lower alu to scalar so that all alu ops on doubles
only take one input. Then, we can use our new double lowering pass.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Jesse Natalie 771c223f60 microsoft/compiler: Implement new double pack/unpack alu ops
MakeDouble is pretty straightforward, but SplitDouble is interesting
since it returns a unique 2-element struct.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Jesse Natalie 5578fdd2c4 microsoft/compiler: Add a lowering pass to emit double [un]pack instructions
Whenever we have an ALU op that's operating on a double, we'll unpack
it as an integer, then repack it as a float. When we have an ALU op that
returns a double, we'll unpack it as a double, then repack it as an integer.

Then, simple algebraic opts will remove any redundant unpack/repack ops,
so we should be left with constructing and deconstructing doubles using
the right operations.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Jesse Natalie bd219321a5 microsoft/compiler: Support fp16 i/o vars
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Jesse Natalie 79bcefa8d9 microsoft/spirv_to_dxil: Lower io arrays
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Jesse Natalie cac3aedb0f microsoft/spirv_to_dxil: Lower globals to function_temp
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10063>
2021-04-09 01:54:33 +00:00
Bas Nieuwenhuizen 580f1ac473 nir: Extract shader_info->cs.shared_size out of union.
It is valid for all stages, just 0 for most of them. In particular
mesh/task shaders might be using it.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10094>
2021-04-08 14:39:28 +00:00
Enrico Galli ad88e2f959 microsoft/spirv_to_dxil: Use non-zero exit code on failed compilations
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10064>
2021-04-07 23:50:39 +00:00
Enrico Galli 5756f2cd2c microsoft/spirv_to_dxil: Add support for load_vulkan_descriptor
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10064>
2021-04-07 23:50:39 +00:00
Jesse Natalie 91dbad7956 microsoft/compiler: Fix barrier flag for shared memory
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10010>
2021-04-05 15:58:03 +00:00
Jesse Natalie f447c69653 spirv_to_dxil: Handle clip/cull distance
Clip/cull only needs a little bit of lowering before nir_to_dxil can
handle it. Specifically, we just need to split apart arrays that
straddle the 4-component boundary of location, so that the signature
builder can handle it.

To do that cleanly, we need to add some lowering and optimization passes:
* nir_lower_clip_cull_distance_arrays: Merge clip/cull into a single array,
  which is similar to DXIL's requirements here.
* nir_lower_io_to_temporaries: Ensure that we only have one non-indirect write
  to the clip/cull output.
* nir_split_var_copies and nir_lower_var_copies: Ensure that each array entry
  has an independent write with a constant index
* Optimization loop: Make sure that there's no extra derefs in the way between
  deref_var for the output, deref_array for the component, and store_deref.
Then we can actually lower the clip/cull array cleanly.

Still to do is to sort the variables and add driver_location.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Jesse Natalie 39aa32b838 microsoft/spirv_to_dxil: Implement TODO for removing dead functions
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Jesse Natalie baeb363df0 microsoft/compiler: Support compact arrays for clip/cull in nir_to_dxil
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Acked-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Jesse Natalie 4941decc58 microsoft/compiler: Enable dxil_nir.h to be included from C++
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Acked-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Jesse Natalie 65e1bee99c microsoft/compiler: Add a lowering pass to split clip/cull distance compact arrays
As the pass's comment explains, NIR compact arrays are a better match
to represent the GLSL float[] design of clip/cull distance arrays, compared
to the float4[2] approach. This pass adjusts the variables to more closely
match what DXIL signatures would look like for that representation.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Acked-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Jesse Natalie 96cd961853 microsoft/compiler: Add copy_prop_vars to optimization loop
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Acked-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Jesse Natalie 3f1b90d638 microsoft/compiler: Move blob_init earlier to prevent crash on failure
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Acked-by: Michael Tang <tangm@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Michael Tang cb5120bcf7 microsoft/spirv_to_dxil: Add extra lowering functions according to the docs on nir_inline_functions
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Michael Tang 2f3dc0264c microsoft/spirv_to_dxil: Add lowering pass to handle gl_PerVertex
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9846>
2021-04-02 17:16:48 +00:00
Dave Airlie 01dfd65a2d nir: port fp16 casting code from dxil
This moves the dxil pass to common code and makes dxil
use the new code.

Acked-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9643>
2021-03-22 12:16:59 +10:00
Michael Tang 8016a098fc microsoft/spirv_to_dxil: Fix spirv2dxil I/O to use binary mode
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9513>
2021-03-11 23:43:47 +00:00
Jesse Natalie fe90bcf11a microsoft/compiler: Don't separate phis while inserting upcasts
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4414
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9464>
2021-03-09 01:41:32 +00:00
Jason Ekstrand e20e85f01e nir: Make nir_ssa_def_rewrite_uses_after take an SSA value
This replaces the new_src parameter of nir_ssa_def_rewrite_uses_after()
with an SSA def, and rewrites all the users as needed.

Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00
Jason Ekstrand 117668b811 nir: Make nir_ssa_def_rewrite_uses take an SSA value
This commit replaces the new_src parameter of nir_ssa_def_rewrite_uses()
with an SSA def, removes nir_ssa_def_rewrite_uses_ssa(), and rewrites
all the users as needed.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00
Christian Gmeiner 3fbde2fd93 nir: add has_txs flag
Some nir lowerings might need to know if txs is supported by
the backend.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8898>
2021-02-23 14:04:30 +00:00
Jesse Natalie 8a3dbf1ca6 microsoft/clc: Add a test with an unused kernel arg
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9160>
2021-02-19 16:36:46 +00:00
Jesse Natalie 11061c4e28 microsoft/clc: Re-order dead variable removal after uniform vars_to_explicit_types
Since vars_to_explicit_types is now where driver_location/offset is filled out,
we need to make sure that we still have all app-provided kernel arg variables
at that point in time so they all get assigned unique offsets. That means
that we can't have removed dead uniforms yet, which also means we can't have
filled out metadata for inline samplers (since usage of them generates tons
of duplicate uniforms).

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9160>
2021-02-19 16:36:46 +00:00
Jesse Natalie 5b0a10823b microsoft/clc: Use driver_location for metadata instead of re-computing offsets
Fixes: ff05da7f ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9138>
2021-02-18 21:33:54 +00:00
Jesse Natalie 3ee8f2ccba microsoft/clc: Move inline samplers to the end of the variable list
Since inline samplers are uniforms, just like kernel args, and
nir_lower_vars_to_explicit_types will assign driver_location based
on order in the variable list, move the inline samplers to the end
of the list to prevent them from creating gaps in the kernel arg
offsets.

Fixes: ff05da7f ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9138>
2021-02-18 21:33:54 +00:00
Jesse Natalie d773257012 microsoft/clc: Fix wrap modes for inline samplers for integer textures
Fixes: ff05da7f ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9138>
2021-02-18 21:33:54 +00:00
Jesse Natalie 9da8179a1e microsoft/clc: Let lower_vars_to_explicit_types fill kernel input driver_location
Importantly, also run that before mucking with the variable list via image lowering,
which removes and inserts variables, making the driver_location no longer line up
with metadata.

Fixes: ff05da7f ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9138>
2021-02-18 21:33:54 +00:00
Jesse Natalie 6f729a7c9d microsoft/clc: Only apply float scaling to 32bit fdiv
Reviewed By: Bill Kristiansen <billkris@microsoft.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9091>
2021-02-17 19:01:02 +00:00
Jesse Natalie 37142847fa microsoft/clc: Add test with inline function
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9085>
2021-02-16 22:11:21 +00:00
Jesse Natalie c1b8629b2c microsoft/clc: Add -fgnu89-inline to clang args
Without this, inline functions don't have their body emitted in the
resulting LLVM IR, meaning the kernel will fail to link.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9085>
2021-02-16 22:11:21 +00:00
Michael Tang f026345b34 microsoft/compiler: Make resource_state_manager only build with_gallium_d3d12
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8785>
2021-01-29 12:54:02 -08:00
James Park bef0af3f21 microsoft: Fix comma in variadic macro for MSVC
New preprocessor seems to be enabled by default when C17 mode is active.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8772>
2021-01-29 05:43:31 +00:00
Caio Marcelo de Oliveira Filho 9f3d5e99ea compiler: Use util/bitset.h for system_values_read
It is currently a bitset on top of a uint64_t but there are already
more than 64 values.  Change to use BITSET to cover all the
SYSTEM_VALUE_MAX bits.

Cc: mesa-stable
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Acked-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8585>
2021-01-26 20:20:47 +00:00
Connor Abbott c81389ace0 dxil: Use sized types for nir_tex_instr::dest_type
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7989>
2021-01-25 11:21:42 +01:00
Daniel Schürmann bd8e84eb8d nir: replace .lower_sub with .has_fsub and .has_isub
This allows a more fine-grained control about whether
a backend supports one of these instructions.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6597>
2021-01-11 19:13:51 +00:00
Daniel Schürmann b3ce55b445 nir,vc4: Lower fneg to fmul(x, -1.0)
This patch also replaces lower_negate with lower_ineg / lower_fneg.

The fneg semantics have been clarified as of Version 1.5, Revision 1
of the SPIR-V specification, which means that the previous lowering
to fsub is not a viable solution anymore, and is replaced with
lowering to fmul(x, -1.0).

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6597>
2021-01-11 19:13:51 +00:00
Erik Faye-Lund 6f3a34e75c microsoft/compiler: do not lower away 64-bit ffma
In DXIL, the FMA instruction only supports 64-bit operations. However,
back when we implemented support for this, there were only a single
switch for lowering all ffma instructions, so we couldn't easily use it.

But now that there's separate flags to lower ffma on 16, 32 and 64 bit,
we can lower 16 and 32 bit ffmas, and leave 64 bit ffmas alone.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8349>
2021-01-08 15:09:23 +00:00
Erik Faye-Lund c2fa965cc3 microsoft/compiler: correct dxil fma opcode
When I originally added the FFMA opcode here, I added the FMAD opcode
instead of the FMA opcode. The reason for this is that it works on
32-bit values as well, so that seemed like a better fit.

But that's not correct, as the FMA opcode isn't a fused operation, so
let's correct the opcode.

This isn't currently in use, because we currently lower away all ffma
opcodes on the NIR level, but that's about to change.

While we're at it, let's also update the opcode name to match the DXIL
documentation.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8349>
2021-01-08 15:09:23 +00:00
Christian Gmeiner c6d65bb01e microsoft/compiler: use intrinsic builders
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8295>
2021-01-06 14:34:41 +00:00
Jesse Natalie dcd8adcc28 microsoft/clc: Fix const violations from ralloc_steal
Fixes: ff05da7f8d ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7697>
2021-01-04 22:05:02 +00:00
Adam Jackson 8ddddfb516 treewide: Disambiguate various variables named "debug_options"
Name them after what they control so 'vi -t' can take you somewhere
useful.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8165>
2021-01-04 20:51:28 +00:00
Jesse Natalie 24dcdc3fa9 microsoft/compiler: Fix clang fallthrough warnings
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie 72d7e173e3 microsoft/resource_state_manager: Remove unused private variable
Clang detects that this variable is unused. We can re-add it if
we end up needing it but for now let's just remove it.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie c11f2f5de8 microsoft/compiler: Fix tautological comparison
Clang detects that a signed character can't be >= 128. Instead,
we should just explicitly check for the 8th bit via bitmask compare.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie f0eda8fbf8 microsoft/compile: Fix incorrect enum type in function signature
Clang warns for passing one enum type where another was expected.
This was just a copy/paste bug, and had no real impact since the
enum was just used as an integer in this function.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie cda9d44bae microsoft/resoure_state_manager: Silence GCC invalid offsetof warning
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie bd97f401dc microsoft/compiler: Fix incorrect size passed to strncpy
GCC correctly detects/warns that this was the wrong size

Fixes: b9c61379 ("microsoft/compiler: translate nir to dxil")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie bb6a1f5b1e microsoft/compiler: Fix warnings produced by GCC in release mode
Inline some variables/functions that are only used for asserts.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
2021-01-03 23:07:21 +00:00
Jesse Natalie 4dbcf24f68 microsoft/clc: Hook up printf
Rewrites the original lowering pass to use the one shared with Clover,
instead only handling the new load_printf_buffer_address intrinsic.

Exports the new metadata to the runtime containing strings and arg sizes.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8254>
2020-12-28 15:55:08 -08:00
Vinson Lee 512ca3464d d3d12: Initialize TransitionableResourceState m_SupportsSimultaneousAccess.
Fix defect reported by Coverity Scan.

Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member m_SupportsSimultaneousAccess is
not initialized in this constructor nor in any functions that it calls.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8192>
2020-12-24 22:02:00 +00:00
Michael Tang 0b3379c7be microsoft/compiler: Add spirv2dxil executable
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/8043>
2020-12-22 13:28:22 -08:00
Michael Tang 67e48bee1e microsoft/compiler: Add dedicated spirv_to_dxil libraries
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/8043>
2020-12-22 13:28:21 -08:00
Jesse Natalie da9b6a21f4 d3d12: Include wsl/winadapter.h when not compiling for Windows
The winadapter.h provides typedefs and defines to enable the
D3D/DXCore headers to be included as-is when targeting non-
Windows platforms.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7937>
2020-12-16 16:25:54 +00:00
Jesse Natalie 4ee55769d6 microsoft/compiler: Pick up new dxcapi.h
This is more up-to-date with what's on GitHub, and more importantly,
it embeds some of the non-Windows support logic in the header, instead
of shelling out to a nonexistent header.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7937>
2020-12-16 16:25:54 +00:00
Jesse Natalie bc5f69faee d3d12: Use DirectX-Headers wrap for d3d12.h
This does 2 things for us:
1. Allows us to compile-time depend on any features from new headers,
   instead of having to conditionally compile based on Windows SDK version.
2. Allows us to reference d3d12.h when compiling for non-Windows.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7937>
2020-12-16 16:25:54 +00:00
Erik Faye-Lund 2c9e7f73ad microsoft/clc: increase test-timeout
The test "clc_compiler_test" is kinda nasty in packing too many things
into a single test, making it awkwardly long. We should really consider
splitting it up into multiple tests instead.

But right now, it's sometimes timing out on CI, which is bad, so here's
a quick band-aid to prevent this from happening.

The previous timeout of two minutes seems to not always be sufficient
under various loads, so let's add another minute just to be sure.

Here's an example of a failure with the current timeout:

https://gitlab.freedesktop.org/mesa/mesa/-/jobs/5918980#L1589

Fixes: ff05da7f8d ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7872>
2020-12-02 14:19:19 +00:00
Erik Faye-Lund 3517b6fd53 microsoft/clc: add missing dependency
We include git_sha1.h in clc_compiler.c, so we should also make sure we
depend on the header being generated in time. This fixes a spurious
build error when compiling with many cores, like we do on CI.

Fixes: ff05da7f8d ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7869>
2020-12-02 13:41:24 +00:00
Erik Faye-Lund 84dd4ac1c7 microsoft/clc: use files-function for source-list
This makes things a bit more explicit, and is generally what we seem to
do around in the source-tree.

Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7869>
2020-12-02 13:41:24 +00:00
Jesse Natalie c1c1bad582 d3d12: Fix GCC warnings for missing function prototypes
Most of these are adding 'static', for functions that are local
to a translation unit but weren't declared static.

There's one instance of a missing include for bringing the prototype
into the translation unit, one function missing a return type (default-int),
and one which added inline to avoid it being considered unused in some sources.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:47 +00:00
Jesse Natalie 30e5abe5f5 microsoft/compiler: Add missing 'return' to switch case
Fixes: b9c61379 ("microsoft/compiler: translate nir to dxil")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:47 +00:00
Jesse Natalie e593329b0c microsoft/compiler: Misc fixes caught by GCC
* Fix const-correctness on dxil_mdnode pointer arrays
* Fix warning for a missing scope in a case block

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:47 +00:00
Jesse Natalie 4e481a1f65 microsoft/compiler: Fix unhandled switch case warnings
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:47 +00:00
Jesse Natalie 244a41d6a8 d3d12: Remove Windows-specific macros
These all have trivial standard or Mesa replacements

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:47 +00:00
Jesse Natalie 4358af87e7 d3d12: Fix signed-unsigned comparison warnings
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:47 +00:00
Jesse Natalie 6060291c0e d3d12: Fix brace-initialization issues
For C++ code, we shouldn't use {0}, instead use {} to default-
initialize everything. For code with nested structs/unions, make
sure there's enough braces to appropriately scope initialization.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:46 +00:00
Jesse Natalie c3bf781cb0 microsoft/compiler: Remove dead code/variables
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
2020-12-01 17:10:46 +00:00
Erik Faye-Lund f9e4c0ada1 d3d12: lower bitfield_extract to shifts
This wasn't implemented yet, because we hadn't encountered it yet. But
now it seems we can trigger this, thanks to the nv_copy_depth_to_color
piglit tests.

This makes the test go from crash to fail, which isn't perfect, but it's
better than nothing.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7855>
2020-12-01 13:59:30 +00:00
Daniel Stone ad90e9fee6 microsoft/clc: Disable broken f32 -> i64/u64 test
Saturated conversions from f32 -> i64/u64 need to be reworked in the
upstream tree. Disable this test until we've done so, since it doesn't
pass currently.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7537>
2020-11-27 11:22:07 +00:00
Daniel Stone 3a134abab8 microsoft/clc: Allow building with Clang git
clang's version argument will return '1.2.3git' when built from a
non-release source tree, but the resource directory will be '1.2.3'.
Strip the 'git' suffix if it's there.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7537>
2020-11-27 11:22:07 +00:00
Jesse Natalie ff05da7f8d microsoft: Add CLC frontend and kernel/compute support to DXIL converter
This adds a standalone library which can convert through the pipeline of
OpenCL C -> SPIR -> SPIR-V -> NIR -> DXIL. It can add in the libclc
implementations of various library functions in the NIR phase, and
also massages the NIR to shift it more towards graphics-style compute.

This is leveraged by the out-of-tree OpenCLOn12 runtime
(https://github.com/microsoft/OpenCLOn12).

This is the combination of a lot of commits from our development branch,
containing code by several authors.

Co-authored-by: Boris Brezillon <boris.brezillon@collabora.com>
Co-authored-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7565>
2020-11-18 04:05:37 +00:00
Vinson Lee 791fecfae1 microsoft/compiler: Add scope for declaration in case statement.
This patch fixes this build error.

../src/microsoft/compiler/dxil_nir.c: In function 'extract_comps_from_vec32':
../src/microsoft/compiler/dxil_nir.c:52:10: error: a label can only be part of a statement and a declaration is not a statement
   52 |          unsigned dst_offs = i * comps_per32b;
      |          ^~~~~~~~

Fixes: b9c61379ab ("microsoft/compiler: translate nir to dxil")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
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/7563>
2020-11-18 03:38:37 +00:00
Vinson Lee f4c240f34d microsoft/compiler: Add struct glsl_type forward declaration.
This patch fixes this build error.

In file included from ../src/microsoft/compiler/dxil_enums.c:24:
../src/microsoft/compiler/dxil_enums.h:323:58: warning: 'struct glsl_type' declared inside parameter list will not be visible outside of this definition or declaration
  323 | enum dxil_component_type dxil_get_comp_type(const struct glsl_type *type);
      |                                                          ^~~~~~~~~
../src/microsoft/compiler/dxil_enums.h:325:71: warning: 'struct glsl_type' declared inside parameter list will not be visible outside of this definition or declaration
  325 | enum dxil_prog_sig_comp_type dxil_get_prog_sig_comp_type(const struct glsl_type *type);
      |                                                                       ^~~~~~~~~
../src/microsoft/compiler/dxil_enums.h:327:61: warning: 'struct glsl_type' declared inside parameter list will not be visible outside of this definition or declaration
  327 | enum dxil_resource_kind dxil_get_resource_kind(const struct glsl_type *type);
      |                                                             ^~~~~~~~~
../src/microsoft/compiler/dxil_enums.c:31:30: error: conflicting types for 'dxil_get_prog_sig_comp_type'
   31 | enum dxil_prog_sig_comp_type dxil_get_prog_sig_comp_type(const struct glsl_type *type)
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/microsoft/compiler/dxil_enums.c:24:
../src/microsoft/compiler/dxil_enums.h:325:30: note: previous declaration of 'dxil_get_prog_sig_comp_type' was here
  325 | enum dxil_prog_sig_comp_type dxil_get_prog_sig_comp_type(const struct glsl_type *type);
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: b9c61379ab ("microsoft/compiler: translate nir to dxil")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
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/7562>
2020-11-18 03:31:47 +00:00
Vinson Lee 6a4407d269 microsoft/compiler: Add struct dxil_features forward declaration.
This patch fixes this build error.

In file included from ../src/microsoft/compiler/dxil_container.c:24:
../src/microsoft/compiler/dxil_container.h:98:42: warning: ‘struct dxil_features’ declared inside parameter list will not be visible outside of this definition or declaration
   98 |                             const struct dxil_features *features);
      |                                          ^~~~~~~~~~~~~
../src/microsoft/compiler/dxil_container.c:72:1: error: conflicting types for ‘dxil_container_add_features’
   72 | dxil_container_add_features(struct dxil_container *c,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/microsoft/compiler/dxil_container.c:24:
../src/microsoft/compiler/dxil_container.h:97:1: note: previous declaration of ‘dxil_container_add_features’ was here
   97 | dxil_container_add_features(struct dxil_container *c,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: b9c61379ab ("microsoft/compiler: translate nir to dxil")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
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/7560>
2020-11-18 03:22:35 +00:00
Jesse Natalie e7f8c195d8 microsoft/compiler: Fix reference to renamed intrinsic getter
Fixes: b9c61379 ("microsoft/compiler: translate nir to dxil")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7609>
2020-11-16 10:31:49 +00:00
Erik Faye-Lund 314f18b22a microsoft/compiler: correct typo
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7578>
2020-11-13 08:35:34 +00:00
Erik Faye-Lund 4c82cdcb7e microsoft/compiler: inline some struct-declarations
We don't need to refer to these by name anywhere, so let's just inline
these for readability reasons.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7578>
2020-11-13 08:35:34 +00:00
Erik Faye-Lund b9a99b22aa microsoft/compiler: move c++ higher up
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7578>
2020-11-13 08:35:34 +00:00
Erik Faye-Lund a2a35b2d20 microsoft/compiler: remove unused struct
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7578>
2020-11-13 08:35:34 +00:00
Vinson Lee 50175716d2 microsoft/compiler: Add dxil_nir_lower_16bit_conv prototype.
Fix missing-prototypes build error.

src/microsoft/compiler/dxil_nir_algebraic.c:5761:1: error: no previous prototype for ‘dxil_nir_lower_16bit_conv’ [-Werror=missing-prototypes]
 5761 | dxil_nir_lower_16bit_conv(nir_shader *shader)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: b9c61379ab ("microsoft/compiler: translate nir to dxil")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7559>
2020-11-11 12:09:52 -08:00
Erik Faye-Lund bd5f928506 d3d12: ensure all compoents of clip-distances are written
This fixes a regression that happened after rebasing on master, where we
end up not writing all components of the clip-distance array, which the
DXIL validation code in the D3D12 runtime treats as an error.

To ensure we don't end up overwriting a previous wrire, enable
nir_shader_compiler_options::lower_all_io_to_temps as well.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7477>
2020-11-10 15:37:07 +00:00
BillKristiansen 3f31cf64e4 microsoft: add resource state manager utility code
The code originates from this repository:
https://github.com/microsoft/D3D12TranslationLayer

It will be used in the next commit.

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7477>
2020-11-10 15:37:07 +00:00
Erik Faye-Lund b9c61379ab microsoft/compiler: translate nir to dxil
Here's the code to emit DXIL code from NIR. It's big and bulky as-is,
and it needs to be split up a bit.

This is the combination of a lot of commits from our development branch,
containing code by several authors.

Co-authored-by: Bill Kristiansen <billkris@microsoft.com>
Co-authored-by: Boris Brezillon <boris.brezillon@collabora.com>
Co-authored-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Gert Wollny <gert.wollny@collabora.com>
Co-authored-by: Jesse Natalie <jenatali@microsoft.com>
Co-authored-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7477>
2020-11-10 15:37:07 +00:00
Erik Faye-Lund dd5fe2f3de microsoft/compiler: add dxil-util code
This is support-code to emit the DirectX Intermediate Language, which is
a dialect of LLVM 3.7 bitcode. Because modern versions of LLVM doesn't
support emitting bitcode for older versions, and we can't rely on an old
LLVM version because we need the OpenCL support from Clang later on, we
instead implement our own LLVM bitcode encoder as part of this work.

See the official DXIL documentation for more details on DXIL:
https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst

The reason this comes as a separate library, is because we're also using
this code as the basis for an OpenCL C compiler, which will follow as a
separate merge-request later.

This is the combination of more than 230 commits from our development
branch, including the work from several authors.

Co-authored-by: Bill Kristiansen <billkris@microsoft.com>
Co-authored-by: Boris Brezillon <boris.brezillon@collabora.com>
Co-authored-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Gert Wollny <gert.wollny@collabora.com>
Co-authored-by: Jesse Natalie <jenatali@microsoft.com>
Co-authored-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7477>
2020-11-10 15:37:07 +00:00