summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Piñeiro <[email protected]>2019-01-17 13:20:54 +0100
committerArcady Goldmints-Orlov <[email protected]>2019-06-30 16:58:26 -0500
commit39f4ef57d69dd6dad74565db82c519e900998153 (patch)
tree255b920a1c0e130c0118b2c9af6b23b4a53961d7
parent0019d6152749fab000c12daf4d3c7b0d4fba2caf (diff)
nir_types: add glsl_type_is_leaf helper
Helper used to know when a glsl_type is a leaf when iteraring through a complex type. Note that GLSL IR linking also uses the concept of leaf while doing the same iteration, although in that case it uses a visitor. See link_uniform_blocks, process_array_leaf and others as reference. Signed-off-by: Alejandro Piñeiro <[email protected]> Signed-off-by: Antia Puentes <[email protected]> v2: * Moved from gl_nir_linker to nir_types, so it could be used on nir xfb gathering (Timothy Arceri) * Minor update after Timothy's series about record to struct renaming landed master. Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r--src/compiler/nir_types.cpp13
-rw-r--r--src/compiler/nir_types.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 69f89a7fd74..3b6362e66fa 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -727,3 +727,16 @@ glsl_get_explicit_size(const struct glsl_type *type, bool align_to_stride)
{
return type->explicit_size(align_to_stride);
}
+
+bool
+glsl_type_is_leaf(const struct glsl_type *type)
+{
+ if (glsl_type_is_struct_or_ifc(type) ||
+ (glsl_type_is_array(type) &&
+ (glsl_type_is_array(glsl_get_array_element(type)) ||
+ glsl_type_is_struct_or_ifc(glsl_get_array_element(type))))) {
+ return false;
+ } else {
+ return true;
+ }
+}
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 806ba824084..9efe4b4770c 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -202,6 +202,8 @@ const struct glsl_type *glsl_atomic_uint_type(void);
unsigned glsl_type_get_sampler_count(const struct glsl_type *type);
unsigned glsl_type_get_image_count(const struct glsl_type *type);
+bool glsl_type_is_leaf(const struct glsl_type *type);
+
#ifdef __cplusplus
}
#endif