summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2016-10-05 11:58:59 -0700
committerKenneth Graunke <kenneth@whitecape.org>2016-10-06 02:13:36 -0700
commitf7659e02c320fa9aac82e094e01786d2a5eb91e3 (patch)
tree2314a4e4023bf8efcb612c5017a0806ff9e88787
parent0408d50f43d8520d9feb3faef6e6f31871d18a74 (diff)
nir: Delete open coded type printing.
glsl_print_type() prints arrays of arrays incorrectly. For example, a type with name float[3][7] would be printed as float[7][3]. (This is an array of length 3 containing arrays of 7 floats.) cdecl says that the type name is correct. glsl_print_type() doesn't really do anything above and beyond printing type->name, and glsl_print_struct() wasn't used at all. So, drop them. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
-rw-r--r--src/compiler/nir/nir_print.c14
-rw-r--r--src/compiler/nir_types.cpp30
-rw-r--r--src/compiler/nir_types.h3
3 files changed, 11 insertions, 36 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 9fa024ea78..35f64684d2 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -391,9 +391,8 @@ print_var_decl(nir_variable *var, print_state *state)
const char *const wonly = (var->data.image.write_only) ? "writeonly " : "";
fprintf(fp, "%s%s%s%s%s", coher, volat, restr, ronly, wonly);
- glsl_print_type(var->type, fp);
-
- fprintf(fp, " %s", get_var_name(var, state));
+ fprintf(fp, "%s %s", glsl_get_type_name(var->type),
+ get_var_name(var, state));
if (var->data.mode == nir_var_shader_in ||
var->data.mode == nir_var_shader_out ||
@@ -457,8 +456,8 @@ static void
print_arg(nir_variable *var, print_state *state)
{
FILE *fp = state->fp;
- glsl_print_type(var->type, fp);
- fprintf(fp, " %s", get_var_name(var, state));
+ fprintf(fp, "%s %s", glsl_get_type_name(var->type),
+ get_var_name(var, state));
}
static void
@@ -1097,14 +1096,13 @@ print_function(nir_function *function, print_state *state)
unreachable("Invalid parameter type");
}
- glsl_print_type(function->params[i].type, fp);
+ fprintf(fp, "%s", glsl_get_type_name(function->params[i].type));
}
if (function->return_type != NULL) {
if (function->num_params != 0)
fprintf(fp, ", ");
- fprintf(fp, "returning ");
- glsl_print_type(function->return_type, fp);
+ fprintf(fp, "returning %s", glsl_get_type_name(function->return_type));
}
fprintf(fp, "\n");
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index f694a84e72..d1458134c0 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -28,32 +28,10 @@
#include "nir_types.h"
#include "compiler/glsl/ir.h"
-void
-glsl_print_type(const glsl_type *type, FILE *fp)
-{
- if (type->base_type == GLSL_TYPE_ARRAY) {
- glsl_print_type(type->fields.array, fp);
- fprintf(fp, "[%u]", type->length);
- } else if ((type->base_type == GLSL_TYPE_STRUCT)
- && !is_gl_identifier(type->name)) {
- fprintf(fp, "%s@%p", type->name, (void *) type);
- } else {
- fprintf(fp, "%s", type->name);
- }
-}
-
-void
-glsl_print_struct(const glsl_type *type, FILE *fp)
-{
- assert(type->base_type == GLSL_TYPE_STRUCT);
-
- fprintf(fp, "struct {\n");
- for (unsigned i = 0; i < type->length; i++) {
- fprintf(fp, "\t");
- glsl_print_type(type->fields.structure[i].type, fp);
- fprintf(fp, " %s;\n", type->fields.structure[i].name);
- }
- fprintf(fp, "}\n");
+const char *
+glsl_get_type_name(const glsl_type *type)
+{
+ return type->name;
}
const glsl_type *
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 6b4f646b20..854d64fd87 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -40,8 +40,7 @@ extern "C" {
struct glsl_type;
#endif
-void glsl_print_type(const struct glsl_type *type, FILE *fp);
-void glsl_print_struct(const struct glsl_type *type, FILE *fp);
+const char *glsl_get_type_name(const struct glsl_type *type);
const struct glsl_type *glsl_get_struct_field(const struct glsl_type *type,
unsigned index);