From: Pierre Moreau Date: Sun, 10 May 2020 21:21:56 +0000 (+0200) Subject: clover/nir: Register callback for translation messages (v2) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a624faeef98cf06e6effb67f95dc92e70e33f165;p=mesa.git clover/nir: Register callback for translation messages (v2) 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: --- 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.