From d8a11bfc0850defbd4d3dd1fdc0de0e8901bfdc4 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 18 Dec 2018 10:30:23 -0600 Subject: [PATCH] glsl_type: Add a C wrapper to get struct field offsets MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Alejandro Piñeiro Reviewed-by: Caio Marcelo de Oliveira Filho --- src/compiler/nir_types.cpp | 7 +++++++ src/compiler/nir_types.h | 3 +++ 2 files changed, 10 insertions(+) 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); -- 2.30.2