[Mesa-stable] [PATCH 3/5] nir/spirv: Add a way to print non-fatal warnings

Jason Ekstrand jason at jlekstrand.net
Thu Jun 2 21:39:18 UTC 2016


Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Cc: "12.0" <mesa-stable at lists.freedesktop.org>
---
 src/compiler/spirv/spirv_to_nir.c | 16 ++++++++++++++++
 src/compiler/spirv/vtn_private.h  |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index d51089f..e8aea73 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -29,6 +29,22 @@
 #include "nir/nir_vla.h"
 #include "nir/nir_control_flow.h"
 #include "nir/nir_constant_expressions.h"
+#include "spirv_info.h"
+
+void
+_vtn_warn(const char *file, int line, const char *msg, ...)
+{
+   char *formatted;
+   va_list args;
+
+   va_start(args, msg);
+   formatted = ralloc_vasprintf(NULL, msg, args);
+   va_end(args);
+
+   fprintf(stderr, "%s:%d WARNING: %s\n", file, line, formatted);
+
+   ralloc_free(formatted);
+}
 
 static struct vtn_ssa_value *
 vtn_undef_ssa_value(struct vtn_builder *b, const struct glsl_type *type)
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 3ecffad..7f5444e 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -417,6 +417,9 @@ vtn_value(struct vtn_builder *b, uint32_t value_id,
    return val;
 }
 
+void _vtn_warn(const char *file, int line, const char *msg, ...);
+#define vtn_warn(...) _vtn_warn(__FILE__, __LINE__, __VA_ARGS__)
+
 struct vtn_ssa_value *vtn_ssa_value(struct vtn_builder *b, uint32_t value_id);
 
 struct vtn_ssa_value *vtn_create_ssa_value(struct vtn_builder *b,
-- 
2.5.0.400.gff86faf



More information about the mesa-stable mailing list