[Mesa-dev] [PATCH 05/15] meson: Check for SPIRV-Tools and llvm-spirv
Karol Herbst
kherbst at redhat.com
Sat May 11 14:07:02 UTC 2019
From: Pierre Moreau <pierre.morrow at free.fr>
Changes since:
* v11 (Karol Herbst):
- only set new defines for clover to speed up recompilation
- remove autotools
* v10:
- Add a new flag (`--enable-opencl-spirv` for autotools, and
`-Dopencl-spirv=true` for meson) for enabling SPIR-V support in
clover, and never automagically enable it without that flag. (Dylan Baker)
- When enabling the SPIR-V support, the SPIRV-Tools and
SPIRV-LLVM-Translator libraries are now required dependencies.
* v7:
- Properly align LLVMSPIRVLib comment (Dylan Baker)
- Only define CLOVER_ALLOW_SPIRV when **both** dependencies are found:
autotools was only requiring one or the other.
* v6: Replace the llvm-spirv repository by the new official
SPIRV-LLVM-Translator.
* v4: Add a comment saying where to find llvm-spirv (Karol Herbst).
* v3:
- make SPIRV-Tools and llvm-spirv optional (Francisco Jerez);
- bump requirement for llvm-spirv to version 0.2
* v2:
- Bump the required version of SPIRV-Tools to the latest release;
- Add a dependency on llvm-spirv.
Reviewed-by: Dylan Baker <dylan at pnwbakers.com> (v10)
Reviewed-by: Karol Herbst <kherbst at redhat.com>
---
meson.build | 13 +++++++++++++
meson_options.txt | 6 ++++++
src/gallium/state_trackers/clover/meson.build | 9 +++++++--
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
index 2cefbb3f204..dba9f35b28b 100644
--- a/meson.build
+++ b/meson.build
@@ -693,6 +693,16 @@ if _opencl != 'disabled'
with_gallium_opencl = true
with_opencl_icd = _opencl == 'icd'
+ with_opencl_spirv = get_option('opencl-spirv')
+ if with_opencl_spirv
+ dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0')
+ # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator
+ dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : '>= 0.2.1')
+ else
+ dep_spirv_tools = null_dep
+ dep_llvmspirvlib = null_dep
+ endif
+
if host_machine.cpu_family().startswith('ppc') and cpp.compiles('''
#if !defined(__VEC__) || !defined(__ALTIVEC__)
#error "AltiVec not enabled"
@@ -702,8 +712,11 @@ if _opencl != 'disabled'
endif
else
dep_clc = null_dep
+ dep_spirv_tools = null_dep
+ dep_llvmspirvlib = null_dep
with_gallium_opencl = false
with_opencl_icd = false
+ with_opencl_spirv = false
endif
gl_pkgconfig_c_flags = []
diff --git a/meson_options.txt b/meson_options.txt
index 1f72faabee8..00f2e7bc949 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -142,6 +142,12 @@ option(
value : 'disabled',
description : 'build gallium "clover" OpenCL state tracker.',
)
+option(
+ 'opencl-spirv',
+ type : 'boolean',
+ value : false,
+ description : 'build gallium "clover" OpenCL state tracker with SPIR-V binary support.',
+)
option(
'd3d-drivers-path',
type : 'string',
diff --git a/src/gallium/state_trackers/clover/meson.build b/src/gallium/state_trackers/clover/meson.build
index 2ff060bf35b..311dcb69a6b 100644
--- a/src/gallium/state_trackers/clover/meson.build
+++ b/src/gallium/state_trackers/clover/meson.build
@@ -19,12 +19,17 @@
# SOFTWARE.
clover_cpp_args = []
+clover_spirv_cpp_args = []
clover_incs = [inc_include, inc_src, inc_gallium, inc_gallium_aux]
if with_opencl_icd
clover_cpp_args += '-DHAVE_CLOVER_ICD'
endif
+if with_opencl_spirv
+ clover_spirv_cpp_args += '-DCLOVER_ALLOW_SPIRV'
+endif
+
libclllvm = static_library(
'clllvm',
files(
@@ -40,7 +45,7 @@ libclllvm = static_library(
),
include_directories : clover_incs,
cpp_args : [
- cpp_vis_args,
+ clover_spirv_cpp_args, cpp_vis_args,
'-DLIBCLC_INCLUDEDIR="@0@/"'.format(dep_clc.get_pkgconfig_variable('includedir')),
'-DLIBCLC_LIBEXECDIR="@0@/"'.format(dep_clc.get_pkgconfig_variable('libexecdir')),
'-DCLANG_RESOURCE_DIR="@0@"'.format(join_paths(
@@ -111,7 +116,7 @@ libclover = static_library(
'clover',
[clover_files, sha1_h],
include_directories : clover_incs,
- cpp_args : [clover_cpp_args, cpp_vis_args],
+ cpp_args : [clover_spirv_cpp_args, clover_cpp_args, cpp_vis_args],
link_with : [libclllvm],
override_options : clover_cpp_std,
)
--
2.21.0
More information about the mesa-dev
mailing list