clover: Hide SPIR-V related code behind HAVE_CLOVER_SPIRV

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25341>
This commit is contained in:
Caio Oliveira 2023-09-21 23:50:14 -07:00 committed by Marge Bot
parent 0e7337e830
commit 3a210932ad
2 changed files with 16 additions and 5 deletions

View 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:

View file

@ -25,14 +25,17 @@
#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 *