From a624faeef98cf06e6effb67f95dc92e70e33f165 Mon Sep 17 00:00:00 2001 From: Pierre Moreau Date: Sun, 10 May 2020 23:21:56 +0200 Subject: [PATCH] clover/nir: Register callback for translation messages (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This allows us to add SPIR-V to NIR translation failure messages to the program’s compilation log, which can then be queried by the user. v2: Replace the if-statement in `debug_function()` with an assert. Signed-off-by: Pierre Moreau Reviewed-by: Serge Martin Reviewed-by: Francisco Jerez Part-of: --- src/gallium/frontends/clover/nir/invocation.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gallium/frontends/clover/nir/invocation.cpp b/src/gallium/frontends/clover/nir/invocation.cpp index 3d7fda8119b..032fb03cfd8 100644 --- a/src/gallium/frontends/clover/nir/invocation.cpp +++ b/src/gallium/frontends/clover/nir/invocation.cpp @@ -58,6 +58,15 @@ dev_get_nir_compiler_options(const device &dev) return static_cast(co); } +static void debug_function(void *private_data, + enum nir_spirv_debug_level level, size_t spirv_offset, + const char *message) +{ + assert(private_data); + auto r_log = reinterpret_cast(private_data); + *r_log += message; +} + module clover::nir::spirv_to_nir(const module &mod, const device &dev, std::string &r_log) { @@ -80,6 +89,8 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev, spirv_options.caps.kernel = true; spirv_options.caps.int64_atomics = dev.has_int64_atomics(); spirv_options.constant_as_global = true; + spirv_options.debug.func = &debug_function; + spirv_options.debug.private_data = &r_log; module m; // We only insert one section. -- 2.30.2