compiler/types: Add glsl_type_uniform_locations() and use it in C++
authorCaio Oliveira <caio.oliveira@intel.com>
Fri, 8 Sep 2023 03:08:37 +0000 (20:08 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 25 Oct 2023 01:51:12 +0000 (01:51 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>

src/compiler/glsl_types.cpp
src/compiler/glsl_types.h
src/compiler/glsl_types_impl.h

index 9e6fead..302e1a5 100644 (file)
@@ -1895,12 +1895,12 @@ glsl_get_struct_location_offset(const struct glsl_type *t, unsigned length)
    return offset;
 }
 
-unsigned
-glsl_type::uniform_locations() const
+extern "C" unsigned
+glsl_type_uniform_locations(const struct glsl_type *t)
 {
    unsigned size = 0;
 
-   switch (this->base_type) {
+   switch (t->base_type) {
    case GLSL_TYPE_UINT:
    case GLSL_TYPE_INT:
    case GLSL_TYPE_FLOAT:
@@ -1921,11 +1921,11 @@ glsl_type::uniform_locations() const
 
    case GLSL_TYPE_STRUCT:
    case GLSL_TYPE_INTERFACE:
-      for (unsigned i = 0; i < this->length; i++)
-         size += this->fields.structure[i].type->uniform_locations();
+      for (unsigned i = 0; i < t->length; i++)
+         size += glsl_type_uniform_locations(t->fields.structure[i].type);
       return size;
    case GLSL_TYPE_ARRAY:
-      return this->length * this->fields.array->uniform_locations();
+      return t->length * glsl_type_uniform_locations(t->fields.array);
    default:
       return 0;
    }
index 1ad5b55..6923cfe 100644 (file)
@@ -1564,6 +1564,7 @@ unsigned glsl_count_dword_slots(const struct glsl_type *t, bool is_bindless);
 unsigned glsl_get_component_slots(const struct glsl_type *t);
 unsigned glsl_get_component_slots_aligned(const struct glsl_type *t, unsigned offset);
 unsigned glsl_varying_count(const struct glsl_type *t);
+unsigned glsl_type_uniform_locations(const struct glsl_type *t);
 
 static inline unsigned
 glsl_count_attribute_slots(const struct glsl_type *t, bool is_gl_vertex_input)
index 2ecd772..63ae0f4 100644 (file)
@@ -69,6 +69,7 @@ inline unsigned glsl_type::count_attribute_slots(bool is_gl_vertex_input) const
 inline unsigned glsl_type::varying_count() const { return glsl_varying_count(this); }
 inline unsigned glsl_type::atomic_size() const { return glsl_atomic_size(this); }
 inline int glsl_type::coordinate_components() const { return glsl_get_sampler_coordinate_components(this); }
+inline unsigned glsl_type::uniform_locations() const { return glsl_type_uniform_locations(this); }
 
 inline unsigned glsl_type::cl_size() const { return glsl_get_cl_size(this); }
 inline unsigned glsl_type::cl_alignment() const { return glsl_get_cl_alignment(this); }