mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
nir: Add an interface for logging shaders with mesa_log*.
For debug on Android, it's useful to be able to print shaders to the android log interface, since you don't usually have stdout/stderr. Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9262>
This commit is contained in:
parent
88fe7ab4fa
commit
990c232603
3 changed files with 24 additions and 2 deletions
|
|
@ -32,6 +32,7 @@
|
|||
#include "compiler/glsl/list.h"
|
||||
#include "GL/gl.h" /* GLenum */
|
||||
#include "util/list.h"
|
||||
#include "util/log.h"
|
||||
#include "util/ralloc.h"
|
||||
#include "util/set.h"
|
||||
#include "util/bitscan.h"
|
||||
|
|
@ -4083,8 +4084,14 @@ void nir_print_shader(nir_shader *shader, FILE *fp);
|
|||
void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table *errors);
|
||||
void nir_print_instr(const nir_instr *instr, FILE *fp);
|
||||
void nir_print_deref(const nir_deref_instr *deref, FILE *fp);
|
||||
void nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag, nir_shader *shader, struct hash_table *annotations);
|
||||
#define nir_log_shadere(s) nir_log_shader_annotated_tagged(MESA_LOG_ERROR, (MESA_LOG_TAG), (s), NULL)
|
||||
#define nir_log_shaderw(s) nir_log_shader_annotated_tagged(MESA_LOG_WARN, (MESA_LOG_TAG), (s), NULL)
|
||||
#define nir_log_shaderi(s) nir_log_shader_annotated_tagged(MESA_LOG_INFO, (MESA_LOG_TAG), (s), NULL)
|
||||
#define nir_log_shader_annotated(s, annotations) nir_log_shader_annotated_tagged(MESA_LOG_ERROR, (MESA_LOG_TAG), (s), annotations)
|
||||
|
||||
char *nir_shader_as_str(nir_shader *nir, void *mem_ctx);
|
||||
char *nir_shader_as_str_annotated(nir_shader *nir, struct hash_table *annotations, void *mem_ctx);
|
||||
|
||||
/** Shallow clone of a single instruction. */
|
||||
nir_instr *nir_instr_clone(nir_shader *s, const nir_instr *orig);
|
||||
|
|
|
|||
|
|
@ -1653,14 +1653,14 @@ nir_print_shader(nir_shader *shader, FILE *fp)
|
|||
}
|
||||
|
||||
char *
|
||||
nir_shader_as_str(nir_shader *nir, void *mem_ctx)
|
||||
nir_shader_as_str_annotated(nir_shader *nir, struct hash_table *annotations, void *mem_ctx)
|
||||
{
|
||||
char *stream_data = NULL;
|
||||
size_t stream_size = 0;
|
||||
struct u_memstream mem;
|
||||
if (u_memstream_open(&mem, &stream_data, &stream_size)) {
|
||||
FILE *const stream = u_memstream_get(&mem);
|
||||
nir_print_shader(nir, stream);
|
||||
nir_print_shader_annotated(nir, stream, annotations);
|
||||
u_memstream_close(&mem);
|
||||
}
|
||||
|
||||
|
|
@ -1673,6 +1673,12 @@ nir_shader_as_str(nir_shader *nir, void *mem_ctx)
|
|||
return str;
|
||||
}
|
||||
|
||||
char *
|
||||
nir_shader_as_str(nir_shader *nir, void *mem_ctx)
|
||||
{
|
||||
return nir_shader_as_str_annotated(nir, NULL, mem_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
nir_print_instr(const nir_instr *instr, FILE *fp)
|
||||
{
|
||||
|
|
@ -1696,3 +1702,11 @@ nir_print_deref(const nir_deref_instr *deref, FILE *fp)
|
|||
};
|
||||
print_deref_link(deref, true, &state);
|
||||
}
|
||||
|
||||
void nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag,
|
||||
nir_shader *shader, struct hash_table *annotations)
|
||||
{
|
||||
char *str = nir_shader_as_str_annotated(shader, annotations, NULL);
|
||||
_mesa_log_multiline(level, tag, str);
|
||||
ralloc_free(str);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ struct intel_perf_query_result;
|
|||
#include "isl/isl.h"
|
||||
|
||||
#include "dev/intel_debug.h"
|
||||
#undef MESA_LOG_TAG
|
||||
#define MESA_LOG_TAG "MESA-INTEL"
|
||||
#include "util/log.h"
|
||||
#include "wsi_common.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue