From: Jason Ekstrand Date: Tue, 18 Dec 2018 16:30:23 +0000 (-0600) Subject: glsl_type: Add a C wrapper to get struct field offsets X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d8a11bfc0850defbd4d3dd1fdc0de0e8901bfdc4;p=mesa.git glsl_type: Add a C wrapper to get struct field offsets Reviewed-by: Alejandro PiƱeiro Reviewed-by: Caio Marcelo de Oliveira Filho --- diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index e0e37e2b289..6995a897d60 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -65,6 +65,13 @@ glsl_get_struct_field(const glsl_type *type, unsigned index) return type->fields.structure[index].type; } +const int +glsl_get_struct_field_offset(const struct glsl_type *type, + unsigned index) +{ + return type->fields.structure[index].offset; +} + const glsl_type * glsl_get_function_return_type(const glsl_type *type) { diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index e7ffad43ad0..6e671b4cc71 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -46,6 +46,9 @@ 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); +const int glsl_get_struct_field_offset(const struct glsl_type *type, + unsigned index); + const struct glsl_type *glsl_get_array_element(const struct glsl_type *type); const struct glsl_type *glsl_without_array(const struct glsl_type *type); const struct glsl_type *glsl_without_array_or_matrix(const struct glsl_type *type);