Mesa (master): compiler: add glsl_print_type
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 17 11:23:59 UTC 2020
Module: Mesa
Branch: master
Commit: f3a9781ee190a81766dcf6243aabef57839ab5a2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3a9781ee190a81766dcf6243aabef57839ab5a2
Author: Marek Olšák <marek.olsak at amd.com>
Date: Thu Aug 13 13:39:38 2020 -0400
compiler: add glsl_print_type
Move it from the glsl compiler. For debugging.
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6328>
---
src/compiler/glsl/ir.h | 3 ---
src/compiler/glsl/ir_print_visitor.cpp | 26 ++++++--------------------
src/compiler/glsl_types.cpp | 14 ++++++++++++++
src/compiler/glsl_types.h | 4 ++++
4 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index e2e46adc855..2ec78f7bdfd 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -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);
diff --git a/src/compiler/glsl/ir_print_visitor.cpp b/src/compiler/glsl/ir_print_visitor.cpp
index 034ee163cf9..7e5e6440a2b 100644
--- a/src/compiler/glsl/ir_print_visitor.cpp
+++ b/src/compiler/glsl/ir_print_visitor.cpp
@@ -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()) {
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index d6315845e68..051d8e8c382 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -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);
+ }
+}
+
}
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index df5ca4629e5..6a57c7026a6 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -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);
More information about the mesa-commit
mailing list