Module: Mesa
Branch: main
Commit: f1502f3f37e541807932a43da841ec9cfaf01e82
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1502f3f37e541807932a43da841ec9cfaf01e82

Author: Caio Oliveira <[email protected]>
Date:   Thu Sep  7 16:49:47 2023 -0700

compiler/types: Flip wrapping of convenience accessors for vector types

Reviewed-by: Kenneth Graunke <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25470>

---

 src/compiler/glsl_types.cpp    | 23 +++++++++++++----------
 src/compiler/glsl_types.h      | 11 ++++++++++-
 src/compiler/glsl_types_impl.h | 13 +++++++++++++
 src/compiler/nir_types.cpp     | 12 ------------
 4 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 4c72b2e9c02..319acb1f2ae 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -543,8 +543,8 @@ glsl_cmat_use_to_string(enum glsl_cmat_use use)
    }
 };
 
-const struct glsl_type *
-glsl_type::vec(unsigned components, const struct glsl_type *const ts[])
+static const struct glsl_type *
+vec(unsigned components, const struct glsl_type *const ts[])
 {
    unsigned n = components;
 
@@ -554,22 +554,25 @@ glsl_type::vec(unsigned components, const struct 
glsl_type *const ts[])
       n = 7;
 
    if (n == 0 || n > 7)
-      return error_type;
+      return &glsl_type_builtin_error;
 
    return ts[n - 1];
 }
 
 #define VECN(components, sname, vname)           \
-const struct glsl_type *                                \
-glsl_type:: vname (unsigned components)          \
+extern "C" const struct glsl_type *              \
+glsl_ ## vname ## _type (unsigned components)    \
 {                                                \
    static const struct glsl_type *const ts[] = { \
-      sname ## _type, vname ## 2_type,           \
-      vname ## 3_type, vname ## 4_type,          \
-      vname ## 5_type,                           \
-      vname ## 8_type, vname ## 16_type,         \
+      &glsl_type_builtin_ ## sname,              \
+      &glsl_type_builtin_ ## vname ## 2,         \
+      &glsl_type_builtin_ ## vname ## 3,         \
+      &glsl_type_builtin_ ## vname ## 4,         \
+      &glsl_type_builtin_ ## vname ## 5,         \
+      &glsl_type_builtin_ ## vname ## 8,         \
+      &glsl_type_builtin_ ## vname ## 16,        \
    };                                            \
-   return glsl_type::vec(components, ts);        \
+   return vec(components, ts);                   \
 }
 
 VECN(components, float, vec)
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 1ac247be3a4..1ca58719934 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -391,7 +391,6 @@ struct glsl_type {
     * Convenience accessors for vector types (shorter than get_instance()).
     * @{
     */
-   static const glsl_type *vec(unsigned components, const glsl_type *const 
ts[]);
    static const glsl_type *vec(unsigned components);
    static const glsl_type *f16vec(unsigned components);
    static const glsl_type *dvec(unsigned components);
@@ -1342,7 +1341,17 @@ const struct glsl_type *glsl_intN_t_type(unsigned 
bit_size);
 const struct glsl_type *glsl_uintN_t_type(unsigned bit_size);
 
 const struct glsl_type *glsl_vec_type(unsigned components);
+const struct glsl_type *glsl_f16vec_type(unsigned components);
 const struct glsl_type *glsl_dvec_type(unsigned components);
+const struct glsl_type *glsl_ivec_type(unsigned components);
+const struct glsl_type *glsl_uvec_type(unsigned components);
+const struct glsl_type *glsl_bvec_type(unsigned components);
+const struct glsl_type *glsl_i64vec_type(unsigned components);
+const struct glsl_type *glsl_u64vec_type(unsigned components);
+const struct glsl_type *glsl_i16vec_type(unsigned components);
+const struct glsl_type *glsl_u16vec_type(unsigned components);
+const struct glsl_type *glsl_i8vec_type(unsigned components);
+const struct glsl_type *glsl_u8vec_type(unsigned components);
 
 const struct glsl_type *glsl_sampler_type(enum glsl_sampler_dim dim,
                                           bool shadow,
diff --git a/src/compiler/glsl_types_impl.h b/src/compiler/glsl_types_impl.h
index d5e9033a387..405a644754c 100644
--- a/src/compiler/glsl_types_impl.h
+++ b/src/compiler/glsl_types_impl.h
@@ -50,6 +50,19 @@ glsl_type::count_attribute_slots(bool is_gl_vertex_input) 
const
    return count_vec4_slots(is_gl_vertex_input, true);
 }
 
+inline const glsl_type *glsl_type::vec(unsigned components) { return 
glsl_vec_type(components); }
+inline const glsl_type *glsl_type::f16vec(unsigned components) { return 
glsl_f16vec_type(components); }
+inline const glsl_type *glsl_type::dvec(unsigned components) { return 
glsl_dvec_type(components); }
+inline const glsl_type *glsl_type::ivec(unsigned components) { return 
glsl_ivec_type(components); }
+inline const glsl_type *glsl_type::uvec(unsigned components) { return 
glsl_uvec_type(components); }
+inline const glsl_type *glsl_type::bvec(unsigned components) { return 
glsl_bvec_type(components); }
+inline const glsl_type *glsl_type::i64vec(unsigned components) { return 
glsl_i64vec_type(components); }
+inline const glsl_type *glsl_type::u64vec(unsigned components) { return 
glsl_u64vec_type(components); }
+inline const glsl_type *glsl_type::i16vec(unsigned components) { return 
glsl_i16vec_type(components); }
+inline const glsl_type *glsl_type::u16vec(unsigned components) { return 
glsl_u16vec_type(components); }
+inline const glsl_type *glsl_type::i8vec(unsigned components) { return 
glsl_i8vec_type(components); }
+inline const glsl_type *glsl_type::u8vec(unsigned components) { return 
glsl_u8vec_type(components); }
+
 inline bool
 glsl_type::is_integer_16() const
 {
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 296c398a619..8062238fd3e 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -307,18 +307,6 @@ glsl_floatN_t_type(unsigned bit_size)
    }
 }
 
-const struct glsl_type *
-glsl_vec_type(unsigned n)
-{
-   return glsl_type::vec(n);
-}
-
-const struct glsl_type *
-glsl_dvec_type(unsigned n)
-{
-   return glsl_type::dvec(n);
-}
-
 const struct glsl_type *
 glsl_vec4_type(void)
 {

Reply via email to