diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2019-02-12 13:03:34 -0600 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-02-25 13:29:14 -0800 |
commit | 5fcd81c5ed377e81b287ef91b4d5d85c6f67266a (patch) | |
tree | 917e2816fb1b44478a22b489a8142855fb874ed9 | |
parent | 67162ad12f31614a4e67610e07bfea460957393f (diff) |
compiler/types: Add a contains_64bit helper
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
(cherry picked from commit 30b548fc6258e9a72722f511e377cf4716fd443c)
-rw-r--r-- | src/compiler/glsl_types.cpp | 16 | ||||
-rw-r--r-- | src/compiler/glsl_types.h | 6 | ||||
-rw-r--r-- | src/compiler/nir_types.cpp | 6 | ||||
-rw-r--r-- | src/compiler/nir_types.h | 1 |
4 files changed, 29 insertions, 0 deletions
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 90f4548030f..042f45a926d 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -261,6 +261,22 @@ glsl_type::contains_double() const } bool +glsl_type::contains_64bit() const +{ + if (this->is_array()) { + return this->fields.array->contains_64bit(); + } else if (this->is_record() || this->is_interface()) { + for (unsigned int i = 0; i < this->length; i++) { + if (this->fields.structure[i].type->contains_64bit()) + return true; + } + return false; + } else { + return this->is_64bit(); + } +} + +bool glsl_type::contains_opaque() const { switch (base_type) { case GLSL_TYPE_SAMPLER: diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index bdaeee7ddd7..bd22fe0dc10 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -545,6 +545,12 @@ public: bool contains_double() const; /** + * Query whether or not type is a 64-bit type, or for struct, interface and + * array types, contains a double type. + */ + bool contains_64bit() const; + + /** * Query whether or not a type is a float type */ bool is_float() const diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index b4bde5470c0..3a406e99769 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -326,6 +326,12 @@ glsl_type_is_integer(const struct glsl_type *type) return type->is_integer(); } +bool +glsl_type_contains_64bit(const struct glsl_type *type) +{ + return type->contains_64bit(); +} + const glsl_type * glsl_void_type(void) { diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index 40cddf76374..8f419817d8c 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -149,6 +149,7 @@ bool glsl_type_is_dual_slot(const struct glsl_type *type); bool glsl_type_is_numeric(const struct glsl_type *type); bool glsl_type_is_boolean(const struct glsl_type *type); bool glsl_type_is_integer(const struct glsl_type *type); +bool glsl_type_contains_64bit(const struct glsl_type *type); bool glsl_sampler_type_is_shadow(const struct glsl_type *type); bool glsl_sampler_type_is_array(const struct glsl_type *type); bool glsl_contains_atomic(const struct glsl_type *type); |