clover: Hide SPIR-V related code behind HAVE_CLOVER_SPIRV
authorCaio Oliveira <caio.oliveira@intel.com>
Fri, 22 Sep 2023 06:50:14 +0000 (23:50 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 22 Sep 2023 15:29:25 +0000 (15:29 +0000)
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25341>

src/gallium/frontends/clover/core/compiler.hpp
src/gallium/frontends/clover/core/device.cpp

index 98002ed..265b280 100644 (file)
@@ -62,16 +62,18 @@ namespace clover {
       static inline binary
       link_program(const std::vector<binary> &bs, const device &dev,
                    const std::string &opts, std::string &log) {
-         const bool create_library =
-            opts.find("-create-library") != std::string::npos;
          switch (dev.ir_format()) {
+#ifdef HAVE_CLOVER_SPIRV
          case PIPE_SHADER_IR_NIR_SERIALIZED: {
+            const bool create_library =
+               opts.find("-create-library") != std::string::npos;
             auto spirv_linked_module = spirv::link_program(bs, dev, opts, log);
             if (create_library)
                return spirv_linked_module;
             return nir::spirv_to_nir(spirv_linked_module,
                                      dev, log);
          }
+#endif
          case PIPE_SHADER_IR_NATIVE:
             return llvm::link_program(bs, dev, opts, log);
          default:
index 59dcaab..848c19b 100644 (file)
 #include "core/platform.hpp"
 #include "pipe/p_screen.h"
 #include "pipe/p_state.h"
-#include "spirv/invocation.hpp"
 #include "util/bitscan.h"
+#include "util/disk_cache.h"
 #include "util/u_debug.h"
-#include "spirv/invocation.hpp"
-#include "nir/invocation.hpp"
 #include "nir.h"
 #include <fstream>
 
+#ifdef HAVE_CLOVER_SPIRV
+#include "spirv/invocation.hpp"
+#include "nir/invocation.hpp"
+#endif
+
 using namespace clover;
 
 namespace {
@@ -525,9 +528,11 @@ device::supported_extensions() const {
       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_fp16" } );
    if (svm_support())
       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_arm_shared_virtual_memory" } );
+#ifdef HAVE_CLOVER_SPIRV
    if (!clover::spirv::supported_versions().empty() &&
        supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED))
       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_il_program" } );
+#endif
    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_extended_versioning" } );
    return vec;
 }
@@ -550,7 +555,11 @@ device::supported_extensions_as_string() const {
 
 std::vector<cl_name_version>
 device::supported_il_versions() const {
+#ifdef HAVE_CLOVER_SPIRV
    return clover::spirv::supported_versions();
+#else
+   return {};
+#endif
 }
 
 const void *