spirv_to_nir: Add environment variable to change default log level
During dEQP runs for radv, I see a lot of warnings like, ERROR - dEQP error: SPIR-V WARNING: ERROR - dEQP error: In file ../src/compiler/spirv/spirv_to_nir.c:1073 ERROR - dEQP error: Decoration not allowed on struct members: SpvDecorationRestrict ERROR - dEQP error: 408 bytes into the SPIR-V binary This fails jobs on Gitlab, due to, Job's log exceeded limit of 4194304 bytes. Job execution will continue but no more output will be collected. Since it doesn't seem feasible right now to fix the many shaders in the VK-CTS triggering this warning, add an environment toggle that allows test runners to only see the level of commentary they want. v2 from Martin: - Add my SoB v3 from Martin: - fix the indentation (suggested by Eric) - put the declarations at the top of the function v4 from Martin: - make vtn_default_log_level() static (Marcin) - cache the default level in vtn_log (Marcin) - move vtn_log_level_strings inside vtn_default_log_level() - Fix the build issue on MSC Signed-off-by: Martin Peres <martin.peres@mupuf.org> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Acked-by: Andres Gomez <agomez@igalia.com> Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11491>
This commit is contained in:
parent
e9991d5ff1
commit
786fa3435c
|
@ -43,6 +43,7 @@ struct nir_spirv_specialization {
|
|||
};
|
||||
|
||||
enum nir_spirv_debug_level {
|
||||
NIR_SPIRV_DEBUG_LEVEL_INVALID = -1,
|
||||
NIR_SPIRV_DEBUG_LEVEL_INFO,
|
||||
NIR_SPIRV_DEBUG_LEVEL_WARNING,
|
||||
NIR_SPIRV_DEBUG_LEVEL_ERROR,
|
||||
|
|
|
@ -34,9 +34,36 @@
|
|||
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_string.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
static enum nir_spirv_debug_level
|
||||
vtn_default_log_level(void)
|
||||
{
|
||||
enum nir_spirv_debug_level level = NIR_SPIRV_DEBUG_LEVEL_WARNING;
|
||||
const char *vtn_log_level_strings[] = {
|
||||
[NIR_SPIRV_DEBUG_LEVEL_WARNING] = "warning",
|
||||
[NIR_SPIRV_DEBUG_LEVEL_INFO] = "info",
|
||||
[NIR_SPIRV_DEBUG_LEVEL_ERROR] = "error",
|
||||
};
|
||||
const char *str = getenv("MESA_SPIRV_LOG_LEVEL");
|
||||
|
||||
if (str == NULL)
|
||||
return NIR_SPIRV_DEBUG_LEVEL_WARNING;
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(vtn_log_level_strings); i++) {
|
||||
if (strcasecmp(str, vtn_log_level_strings[i]) == 0) {
|
||||
level = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return level;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
vtn_log(struct vtn_builder *b, enum nir_spirv_debug_level level,
|
||||
size_t spirv_offset, const char *message)
|
||||
|
@ -47,7 +74,13 @@ vtn_log(struct vtn_builder *b, enum nir_spirv_debug_level level,
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (level >= NIR_SPIRV_DEBUG_LEVEL_WARNING)
|
||||
static enum nir_spirv_debug_level default_level =
|
||||
NIR_SPIRV_DEBUG_LEVEL_INVALID;
|
||||
|
||||
if (default_level == NIR_SPIRV_DEBUG_LEVEL_INVALID)
|
||||
default_level = vtn_default_log_level();
|
||||
|
||||
if (level >= default_level)
|
||||
fprintf(stderr, "%s\n", message);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue