compiler: add glsl_print_type
Move it from the glsl compiler. For debugging. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6328>
This commit is contained in:
parent
b7c04b1790
commit
f3a9781ee1
|
@ -2535,9 +2535,6 @@ extern "C" {
|
|||
extern void _mesa_print_ir(FILE *f, struct exec_list *instructions,
|
||||
struct _mesa_glsl_parse_state *state);
|
||||
|
||||
extern void
|
||||
ir_print_type(FILE *f, const struct glsl_type *t);
|
||||
|
||||
extern void
|
||||
fprint_ir(FILE *f, const void *instruction);
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ _mesa_print_ir(FILE *f, exec_list *instructions,
|
|||
|
||||
for (unsigned j = 0; j < s->length; j++) {
|
||||
fprintf(f, "\t((");
|
||||
ir_print_type(f, s->fields.structure[j].type);
|
||||
glsl_print_type(f, s->fields.structure[j].type);
|
||||
fprintf(f, ")(%s))\n", s->fields.structure[j].name);
|
||||
}
|
||||
|
||||
|
@ -141,20 +141,6 @@ ir_print_visitor::unique_name(ir_variable *var)
|
|||
return name;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
ir_print_type(FILE *f, const glsl_type *t)
|
||||
{
|
||||
if (t->is_array()) {
|
||||
fprintf(f, "(array ");
|
||||
ir_print_type(f, t->fields.array);
|
||||
fprintf(f, " %u)", t->length);
|
||||
} else if (t->is_struct() && !is_gl_identifier(t->name)) {
|
||||
fprintf(f, "%s@%p", t->name, (void *) t);
|
||||
} else {
|
||||
fprintf(f, "%s", t->name);
|
||||
}
|
||||
}
|
||||
|
||||
void ir_print_visitor::visit(ir_rvalue *)
|
||||
{
|
||||
fprintf(f, "error");
|
||||
|
@ -224,7 +210,7 @@ void ir_print_visitor::visit(ir_variable *ir)
|
|||
stream,
|
||||
interp[ir->data.interpolation], precision[ir->data.precision]);
|
||||
|
||||
ir_print_type(f, ir->type);
|
||||
glsl_print_type(f, ir->type);
|
||||
fprintf(f, " %s)", unique_name(ir));
|
||||
|
||||
if (ir->constant_initializer) {
|
||||
|
@ -245,7 +231,7 @@ void ir_print_visitor::visit(ir_function_signature *ir)
|
|||
fprintf(f, "(signature ");
|
||||
indentation++;
|
||||
|
||||
ir_print_type(f, ir->return_type);
|
||||
glsl_print_type(f, ir->return_type);
|
||||
fprintf(f, "\n");
|
||||
indent();
|
||||
|
||||
|
@ -299,7 +285,7 @@ void ir_print_visitor::visit(ir_expression *ir)
|
|||
{
|
||||
fprintf(f, "(expression ");
|
||||
|
||||
ir_print_type(f, ir->type);
|
||||
glsl_print_type(f, ir->type);
|
||||
|
||||
fprintf(f, " %s ", ir_expression_operation_strings[ir->operation]);
|
||||
|
||||
|
@ -323,7 +309,7 @@ void ir_print_visitor::visit(ir_texture *ir)
|
|||
return;
|
||||
}
|
||||
|
||||
ir_print_type(f, ir->type);
|
||||
glsl_print_type(f, ir->type);
|
||||
fprintf(f, " ");
|
||||
|
||||
ir->sampler->accept(this);
|
||||
|
@ -487,7 +473,7 @@ print_float_constant(FILE *f, float val)
|
|||
void ir_print_visitor::visit(ir_constant *ir)
|
||||
{
|
||||
fprintf(f, "(constant ");
|
||||
ir_print_type(f, ir->type);
|
||||
glsl_print_type(f, ir->type);
|
||||
fprintf(f, " (");
|
||||
|
||||
if (ir->type->is_array()) {
|
||||
|
|
|
@ -2971,4 +2971,18 @@ glsl_get_sampler_dim_coordinate_components(enum glsl_sampler_dim dim)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
glsl_print_type(FILE *f, const glsl_type *t)
|
||||
{
|
||||
if (t->is_array()) {
|
||||
fprintf(f, "(array ");
|
||||
glsl_print_type(f, t->fields.array);
|
||||
fprintf(f, " %u)", t->length);
|
||||
} else if (t->is_struct() && !is_gl_identifier(t->name)) {
|
||||
fprintf(f, "%s@%p", t->name, (void *) t);
|
||||
} else {
|
||||
fprintf(f, "%s", t->name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "shader_enums.h"
|
||||
#include "c11/threads.h"
|
||||
|
@ -56,6 +57,9 @@ glsl_type_singleton_decref();
|
|||
extern void
|
||||
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
|
||||
|
||||
void
|
||||
glsl_print_type(FILE *f, const struct glsl_type *t);
|
||||
|
||||
void encode_type_to_blob(struct blob *blob, const struct glsl_type *type);
|
||||
|
||||
const struct glsl_type *decode_type_from_blob(struct blob_reader *blob);
|
||||
|
|
Loading…
Reference in New Issue