compiler/types: Implement glsl_type::field_type() in terms of existing functions
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
This commit is contained in:
@@ -1703,23 +1703,6 @@ glsl_get_mul_type(const struct glsl_type *type_a, const struct glsl_type *type_b
|
||||
return &glsl_type_builtin_error;
|
||||
}
|
||||
|
||||
|
||||
const struct glsl_type *
|
||||
glsl_type::field_type(const char *name) const
|
||||
{
|
||||
if (this->base_type != GLSL_TYPE_STRUCT
|
||||
&& this->base_type != GLSL_TYPE_INTERFACE)
|
||||
return error_type;
|
||||
|
||||
for (unsigned i = 0; i < this->length; i++) {
|
||||
if (strcmp(name, this->fields.structure[i].name) == 0)
|
||||
return this->fields.structure[i].type;
|
||||
}
|
||||
|
||||
return error_type;
|
||||
}
|
||||
|
||||
|
||||
extern "C" int
|
||||
glsl_get_field_index(const struct glsl_type *t, const char *name)
|
||||
{
|
||||
|
||||
@@ -178,6 +178,15 @@ glsl_type::get_explicit_type_for_size_align(glsl_type_size_align_func type_info,
|
||||
inline const glsl_type *glsl_type::replace_vec3_with_vec4() const { return glsl_type_replace_vec3_with_vec4(this); }
|
||||
inline const glsl_type *glsl_type::get_mul_type(const glsl_type *type_a, const glsl_type *type_b) { return glsl_get_mul_type(type_a, type_b); }
|
||||
|
||||
inline const glsl_type *
|
||||
glsl_type::field_type(const char *n) const
|
||||
{
|
||||
const int idx = glsl_get_field_index(this, n);
|
||||
if (idx == -1)
|
||||
return &glsl_type_builtin_error;
|
||||
return glsl_get_struct_field(this, (unsigned)idx);
|
||||
}
|
||||
|
||||
inline bool
|
||||
glsl_type::is_integer_16() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user