From 53149cdd6e161a0421bb835fe9cc9232243e72b1 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Tue, 12 Sep 2023 12:12:33 -0700 Subject: [PATCH] compiler/types: Change glsl_type::name to be an uintptr_t This will allow us later to store builtin names in a different way. Reviewed-by: Adam Jackson Reviewed-by: Ian Romanick Part-of: --- src/compiler/builtin_types_c.py | 2 +- src/compiler/glsl_types.cpp | 10 +++++----- src/compiler/glsl_types.h | 6 +++--- src/compiler/nir_types.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/builtin_types_c.py b/src/compiler/builtin_types_c.py index ecbb56c..cc90228 100644 --- a/src/compiler/builtin_types_c.py +++ b/src/compiler/builtin_types_c.py @@ -23,7 +23,7 @@ const struct glsl_type glsl_type_builtin_${t["name"]} = { %if v is None: <% continue %> %elif k == "name": - .${k} = "${v}", + .name_id = (uintptr_t) "${v}", %else: .${k} = ${v}, %endif diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index cb0b2a3..ff2ce07 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -79,7 +79,7 @@ make_vector_matrix_type(void *lin_ctx, uint32_t gl_type, t->matrix_columns = matrix_columns; t->explicit_stride = explicit_stride; t->explicit_alignment = explicit_alignment; - t->name = linear_strdup(lin_ctx, name); + t->name_id = (uintptr_t)linear_strdup(lin_ctx, name); return t; } @@ -93,7 +93,7 @@ fill_struct_type(glsl_type *t, const glsl_struct_field *fields, unsigned num_fie t->sampled_type = GLSL_TYPE_VOID; t->packed = packed; t->length = num_fields; - t->name = name; + t->name_id = (uintptr_t)name; t->explicit_alignment = explicit_alignment; t->fields.structure = fields; } @@ -132,7 +132,7 @@ fill_interface_type(glsl_type *t, const glsl_struct_field *fields, unsigned num_ t->interface_packing = (unsigned)packing; t->interface_row_major = (unsigned)row_major; t->length = num_fields; - t->name = name; + t->name_id = (uintptr_t)name; t->fields.structure = fields; } @@ -171,7 +171,7 @@ make_subroutine_type(void *lin_ctx, const char *subroutine_name) t->sampled_type = GLSL_TYPE_VOID; t->vector_elements = 1; t->matrix_columns = 1; - t->name = linear_strdup(lin_ctx, subroutine_name); + t->name_id = (uintptr_t)linear_strdup(lin_ctx, subroutine_name); return t; } @@ -522,7 +522,7 @@ make_array_type(void *lin_ctx, const glsl_type *element_type, unsigned length, memcpy(base + array_part, pos, element_part); } - t->name = n; + t->name_id = (uintptr_t)n; return t; } diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index ef5a77d..dfcd0c6 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -324,11 +324,11 @@ struct glsl_type { unsigned length; /** - * Name of the data type + * Identifier to the name of the data type * - * Will never be \c NULL. + * Use glsl_get_type_name() to access the actual name. */ - const char *name; + uintptr_t name_id; /** * Explicit array, matrix, or vector stride. This is used to communicate diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index 15fd71a..1f396cb 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -31,7 +31,7 @@ const char * glsl_get_type_name(const glsl_type *type) { - return type->name; + return (const char *)type->name_id; } int -- 2.7.4