Module: Mesa Branch: main Commit: dd9ced45f54729053de6214b8d6449f41b37662c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd9ced45f54729053de6214b8d6449f41b37662c
Author: Caio Oliveira <[email protected]> Date: Fri Sep 1 22:35:26 2023 -0700 compiler/types: Flip wrapping of base_type checks Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25470> --- src/compiler/glsl_types.h | 33 ++++++++++++--------- src/compiler/glsl_types_impl.h | 25 ++++++++-------- src/compiler/nir_types.cpp | 65 ------------------------------------------ 3 files changed, 31 insertions(+), 92 deletions(-) diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index f292b0df07e..da91a449755 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -1162,20 +1162,25 @@ glsl_get_bit_size(const struct glsl_type *t) return glsl_base_type_get_bit_size(glsl_get_base_type(t)); } -bool glsl_type_is_boolean(const struct glsl_type *t); -bool glsl_type_is_sampler(const struct glsl_type *t); -bool glsl_type_is_texture(const struct glsl_type *t); -bool glsl_type_is_image(const struct glsl_type *t); -bool glsl_type_is_atomic_uint(const struct glsl_type *t); -bool glsl_type_is_struct(const struct glsl_type *t); -bool glsl_type_is_interface(const struct glsl_type *t); -bool glsl_type_is_array(const struct glsl_type *t); -bool glsl_type_is_cmat(const struct glsl_type *t); -bool glsl_type_is_void(const struct glsl_type *t); -bool glsl_type_is_subroutine(const struct glsl_type *t); -bool glsl_type_is_error(const struct glsl_type *t); - -bool glsl_type_is_struct_or_ifc(const struct glsl_type *t); +static inline bool glsl_type_is_boolean(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_BOOL; } +static inline bool glsl_type_is_sampler(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_SAMPLER; } +static inline bool glsl_type_is_texture(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_TEXTURE; } +static inline bool glsl_type_is_image(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_IMAGE; } +static inline bool glsl_type_is_atomic_uint(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_ATOMIC_UINT; } +static inline bool glsl_type_is_struct(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_STRUCT; } +static inline bool glsl_type_is_interface(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_INTERFACE; } +static inline bool glsl_type_is_array(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_ARRAY; } +static inline bool glsl_type_is_cmat(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_COOPERATIVE_MATRIX; } +static inline bool glsl_type_is_void(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_VOID; } +static inline bool glsl_type_is_subroutine(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_SUBROUTINE; } +static inline bool glsl_type_is_error(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_ERROR; } + +static inline bool +glsl_type_is_struct_or_ifc(const struct glsl_type *t) +{ + return glsl_type_is_struct(t) || glsl_type_is_interface(t); +} + bool glsl_type_is_packed(const struct glsl_type *t); bool glsl_type_is_16bit(const struct glsl_type *t); bool glsl_type_is_32bit(const struct glsl_type *t); diff --git a/src/compiler/glsl_types_impl.h b/src/compiler/glsl_types_impl.h index bf4a4290f29..b2ccac7f1b3 100644 --- a/src/compiler/glsl_types_impl.h +++ b/src/compiler/glsl_types_impl.h @@ -12,19 +12,18 @@ #include "compiler/builtin_types_cpp.h" #undef BUILTIN_TYPES_CPP_DEFINITIONS -inline bool glsl_type::is_boolean() const { return base_type == GLSL_TYPE_BOOL; } -inline bool glsl_type::is_sampler() const { return base_type == GLSL_TYPE_SAMPLER; } -inline bool glsl_type::is_texture() const { return base_type == GLSL_TYPE_TEXTURE; } -inline bool glsl_type::is_image() const { return base_type == GLSL_TYPE_IMAGE; } -inline bool glsl_type::is_array() const { return base_type == GLSL_TYPE_ARRAY; } -inline bool glsl_type::is_struct() const { return base_type == GLSL_TYPE_STRUCT; } -inline bool glsl_type::is_interface() const { return base_type == GLSL_TYPE_INTERFACE; } -inline bool glsl_type::is_cmat() const { return base_type == GLSL_TYPE_COOPERATIVE_MATRIX; } -inline bool glsl_type::is_void() const { return base_type == GLSL_TYPE_VOID; } -inline bool glsl_type::is_error() const { return base_type == GLSL_TYPE_ERROR; } -inline bool glsl_type::is_subroutine() const { return base_type == GLSL_TYPE_SUBROUTINE; } -inline bool glsl_type::is_atomic_uint() const { return base_type == GLSL_TYPE_ATOMIC_UINT; } - +inline bool glsl_type::is_boolean() const { return glsl_type_is_boolean(this); } +inline bool glsl_type::is_sampler() const { return glsl_type_is_sampler(this); } +inline bool glsl_type::is_texture() const { return glsl_type_is_texture(this); } +inline bool glsl_type::is_image() const { return glsl_type_is_image(this); } +inline bool glsl_type::is_array() const { return glsl_type_is_array(this); } +inline bool glsl_type::is_struct() const { return glsl_type_is_struct(this); } +inline bool glsl_type::is_interface() const { return glsl_type_is_interface(this); } +inline bool glsl_type::is_cmat() const { return glsl_type_is_cmat(this); } +inline bool glsl_type::is_void() const { return glsl_type_is_void(this); } +inline bool glsl_type::is_error() const { return glsl_type_is_error(this); } +inline bool glsl_type::is_subroutine() const { return glsl_type_is_subroutine(this); } +inline bool glsl_type::is_atomic_uint() const { return glsl_type_is_atomic_uint(this); } inline bool glsl_type::is_scalar() const diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index 59064c46fdc..1c603e69545 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -268,18 +268,6 @@ glsl_type_is_64bit(const struct glsl_type *type) return type->is_64bit(); } -bool -glsl_type_is_void(const struct glsl_type *type) -{ - return type->is_void(); -} - -bool -glsl_type_is_error(const struct glsl_type *type) -{ - return type->is_error(); -} - bool glsl_type_is_vector(const struct glsl_type *type) { @@ -311,12 +299,6 @@ glsl_matrix_type_is_row_major(const struct glsl_type *type) return type->interface_row_major; } -bool -glsl_type_is_array(const struct glsl_type *type) -{ - return type->is_array(); -} - bool glsl_type_is_unsized_array(const struct glsl_type *type) { @@ -335,54 +317,12 @@ glsl_type_is_array_or_matrix(const struct glsl_type *type) return type->is_array() || type->is_matrix(); } -bool -glsl_type_is_cmat(const struct glsl_type *type) -{ - return type->is_cmat(); -} - -bool -glsl_type_is_struct(const struct glsl_type *type) -{ - return type->is_struct(); -} - -bool -glsl_type_is_interface(const struct glsl_type *type) -{ - return type->is_interface(); -} - -bool -glsl_type_is_struct_or_ifc(const struct glsl_type *type) -{ - return type->is_struct() || type->is_interface(); -} - -bool -glsl_type_is_sampler(const struct glsl_type *type) -{ - return type->is_sampler(); -} - bool glsl_type_is_bare_sampler(const struct glsl_type *type) { return type->is_sampler() && type->sampled_type == GLSL_TYPE_VOID; } -bool -glsl_type_is_texture(const struct glsl_type *type) -{ - return type->is_texture(); -} - -bool -glsl_type_is_image(const struct glsl_type *type) -{ - return type->is_image(); -} - bool glsl_sampler_type_is_shadow(const struct glsl_type *type) { @@ -418,11 +358,6 @@ glsl_type_is_numeric(const struct glsl_type *type) return type->is_numeric(); } -bool -glsl_type_is_boolean(const struct glsl_type *type) -{ - return type->is_boolean(); -} bool glsl_type_is_integer(const struct glsl_type *type) {
