mirror of https://gitlab.freedesktop.org/mesa/mesa
nir: add nir_instr_as_str
Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12510>
This commit is contained in:
parent
55b3980e78
commit
97902a9ef8
|
@ -4308,6 +4308,7 @@ void nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag,
|
|||
|
||||
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);
|
||||
char *nir_instr_as_str(const nir_instr *instr, void *mem_ctx);
|
||||
|
||||
/** Shallow clone of a single instruction. */
|
||||
nir_instr *nir_instr_clone(nir_shader *s, const nir_instr *orig);
|
||||
|
|
|
@ -1801,7 +1801,27 @@ nir_print_instr(const nir_instr *instr, FILE *fp)
|
|||
}
|
||||
|
||||
print_instr(instr, &state, 0);
|
||||
}
|
||||
|
||||
char *
|
||||
nir_instr_as_str(const nir_instr *instr, 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_instr(instr, stream);
|
||||
u_memstream_close(&mem);
|
||||
}
|
||||
|
||||
char *str = ralloc_size(mem_ctx, stream_size + 1);
|
||||
memcpy(str, stream_data, stream_size);
|
||||
str[stream_size] = '\0';
|
||||
|
||||
free(stream_data);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue