Changes since: * 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.
Signed-off-by: Pierre Moreau <pierre.mor...@free.fr> --- Dylan, I dropped your Rb since the modification were substantial, even though you were the one asking for them. I could easily have gotten them wrong. :-) configure.ac | 38 ++++++++++++++++++++++++++++++++++++++ meson.build | 12 ++++++++++++ meson_options.txt | 6 ++++++ 3 files changed, 56 insertions(+) diff --git a/configure.ac b/configure.ac index e4d20054d5f..8f00aafae9d 100644 --- a/configure.ac +++ b/configure.ac @@ -1380,6 +1380,12 @@ AC_ARG_ENABLE([opencl_icd], @<:@default=enabled@:>@])], [enable_opencl_icd="$enableval"], [enable_opencl_icd=yes]) +AC_ARG_ENABLE([opencl_spirv], + [AS_HELP_STRING([--enable-opencl-spirv], + [Build an OpenCL library that can consume SPIR-V binaries + @<:@default=enabled@:>@])], + [enable_opencl_spirv="$enableval"], + [enable_opencl_spirv=no]) AC_ARG_ENABLE([gallium-tests], [AS_HELP_STRING([--enable-gallium-tests], @@ -2438,6 +2444,13 @@ AC_ARG_WITH([clang-libdir], PKG_CHECK_EXISTS([libclc], [have_libclc=yes], [have_libclc=no]) +PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools >= 2018.0], + [have_spirv_tools=yes], [have_spirv_tools=no]) + +# LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator +PKG_CHECK_MODULES([LLVMSPIRVLIB], [LLVMSPIRVLib >= 0.2.1], + [have_llvmspirvlib=yes], [have_llvmspirvlib=no]) + if test "x$enable_opencl" = xyes; then if test -z "$with_gallium_drivers"; then AC_MSG_ERROR([cannot enable OpenCL without Gallium]) @@ -2507,9 +2520,34 @@ if test "x$enable_opencl" = xyes; then CLANG_RESOURCE_DIR=$CLANG_LIBDIR/clang/${LLVM_VERSION} AS_IF([test ! -f "$CLANG_RESOURCE_DIR/include/stddef.h"], [AC_MSG_ERROR([Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries.])]) + + if test "x$enable_opencl_spirv" = xyes; then + if test "x$have_spirv_tools" = xno; then + AC_MSG_ERROR([pkg-config cannot find SPIRV-Tools.pc which is + required to build clover with SPIR-V support. + Make sure the directory containing SPIRV-Tools.pc is specified in your + PKG_CONFIG_PATH environment variable.]) + else + if test "x$have_llvmspirvlib" = xno; then + AC_MSG_ERROR([pkg-config cannot find LLVMSPIRVLib.pc which is + required to build clover with SPIR-V support. + Make sure the directory containing LLVMSPIRVLib.pc is specified in your + PKG_CONFIG_PATH environment variable.]) + else + AC_SUBST([SPIRV_TOOLS_CFLAGS]) + AC_SUBST([SPIRV_TOOLS_LIBS]) + + AC_SUBST([LLVMSPIRVLIB_CFLAGS]) + AC_SUBST([LLVMSPIRVLIB_LIBS]) + + DEFINES="$DEFINES -DCLOVER_ALLOW_SPIRV" + fi + fi + fi fi AM_CONDITIONAL(HAVE_CLOVER, test "x$enable_opencl" = xyes) AM_CONDITIONAL(HAVE_CLOVER_ICD, test "x$enable_opencl_icd" = xyes) +AM_CONDITIONAL(CLOVER_ALLOW_SPIRV, test "x$enable_opencl_spirv" = xyes) AC_SUBST([OPENCL_LIBNAME]) AC_SUBST([CLANG_RESOURCE_DIR]) diff --git a/meson.build b/meson.build index e759bbf96a5..069c3b97f72 100644 --- a/meson.build +++ b/meson.build @@ -658,6 +658,16 @@ if _opencl != 'disabled' with_gallium_opencl = true with_opencl_icd = _opencl == 'icd' + if get_option('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') + pre_args += '-DCLOVER_ALLOW_SPIRV' + 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" @@ -667,6 +677,8 @@ 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 endif diff --git a/meson_options.txt b/meson_options.txt index bfb06c4dd42..72b0a00ee9a 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', -- 2.20.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev