summaryrefslogtreecommitdiff
path: root/src/gallium/frontends/clover/core/device.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/frontends/clover/core/device.cpp')
-rw-r--r--src/gallium/frontends/clover/core/device.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gallium/frontends/clover/core/device.cpp b/src/gallium/frontends/clover/core/device.cpp
index 7f3d970ea5f..8ffc58fc2f2 100644
--- a/src/gallium/frontends/clover/core/device.cpp
+++ b/src/gallium/frontends/clover/core/device.cpp
@@ -28,6 +28,9 @@
#include "pipe/p_state.h"
#include "util/bitscan.h"
#include "util/u_debug.h"
+#include "spirv/invocation.hpp"
+#include "nir/invocation.hpp"
+#include <fstream>
using namespace clover;
@@ -45,14 +48,17 @@ namespace {
}
device::device(clover::platform &platform, pipe_loader_device *ldev) :
- platform(platform), ldev(ldev) {
+ platform(platform), clc_cache(NULL), ldev(ldev) {
pipe = pipe_loader_create_screen(ldev);
if (pipe && pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
if (supports_ir(PIPE_SHADER_IR_NATIVE))
return;
#ifdef HAVE_CLOVER_SPIRV
- if (supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED))
+ if (supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED)) {
+ load_clc();
+ clc_nir = lazy<std::shared_ptr<nir_shader>>([&] () { std::string log; return std::shared_ptr<nir_shader>(nir::libclc_spirv_to_nir(clc, *this, log), ralloc_free); });
return;
+ }
#endif
}
if (pipe)
@@ -61,12 +67,25 @@ device::device(clover::platform &platform, pipe_loader_device *ldev) :
}
device::~device() {
+ if (clc_cache)
+ disk_cache_destroy(clc_cache);
if (pipe)
pipe->destroy(pipe);
if (ldev)
pipe_loader_release(&ldev, 1);
}
+void
+device::load_clc() {
+#ifdef HAVE_CLOVER_SPIRV
+ if (supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED)) {
+ std::string log;
+ clc_cache = nir::create_clc_disk_cache();
+ clc = spirv::load_clc(*this);
+ }
+#endif
+}
+
bool
device::operator==(const device &dev) const {
return this == &dev;