gallium/ttn: Add a debug flag for dumping the shaders.

Just like for ntt, it's nice to be able to dump the shader that assertion
failed on you.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11915>
This commit is contained in:
Eric Anholt 2021-01-08 16:04:42 -08:00 committed by Marge Bot
parent 8c36022e0d
commit 11f9ad9238

View file

@ -23,6 +23,7 @@
*/
#include "util/blob.h"
#include "util/debug.h"
#include "util/disk_cache.h"
#include "util/u_memory.h"
#include "util/ralloc.h"
@ -2560,6 +2561,7 @@ tgsi_to_nir(const void *tgsi_tokens,
struct nir_shader *s = NULL;
uint8_t key[CACHE_KEY_SIZE];
unsigned processor;
bool debug = env_var_as_boolean("TGSI_TO_NIR_DEBUG", false);
if (allow_disk_cache)
cache = screen->get_disk_shader_cache(screen);
@ -2577,6 +2579,11 @@ tgsi_to_nir(const void *tgsi_tokens,
if (s)
return s;
if (debug) {
fprintf(stderr, "TGSI before translation to NIR:\n");
tgsi_dump(tgsi_tokens, 0);
}
/* Not in the cache */
c = ttn_compile_init(tgsi_tokens, NULL, screen);
@ -2584,6 +2591,11 @@ tgsi_to_nir(const void *tgsi_tokens,
ttn_finalize_nir(c, screen);
ralloc_free(c);
if (debug) {
mesa_logi("NIR after translation from TGSI:\n");
nir_log_shaderi(s);
}
if (cache)
save_nir_to_disk_cache(cache, key, s);