}
-int
-glsl_type::field_index(const char *name) const
+extern "C" int
+glsl_get_field_index(const struct glsl_type *t, const char *name)
{
- if (this->base_type != GLSL_TYPE_STRUCT
- && this->base_type != GLSL_TYPE_INTERFACE)
+ if (t->base_type != GLSL_TYPE_STRUCT &&
+ t->base_type != GLSL_TYPE_INTERFACE)
return -1;
- for (unsigned i = 0; i < this->length; i++) {
- if (strcmp(name, this->fields.structure[i].name) == 0)
+ for (unsigned i = 0; i < t->length; i++) {
+ if (strcmp(name, t->fields.structure[i].name) == 0)
return i;
}
return 0;
}
-unsigned
-glsl_type::struct_location_offset(unsigned length) const
+extern "C" unsigned
+glsl_get_struct_location_offset(const struct glsl_type *t, unsigned length)
{
unsigned offset = 0;
- const struct glsl_type *t = this->without_array();
+ t = t->without_array();
if (t->is_struct()) {
assert(length <= t->length);
return size;
}
+const struct glsl_type *
+glsl_get_struct_field(const struct glsl_type *t, unsigned index)
+{
+ assert(t->is_struct() || t->is_interface());
+ assert(index < t->length);
+ return t->fields.structure[index].type;
+}
+
+const struct glsl_struct_field *
+glsl_get_struct_field_data(const struct glsl_type *t, unsigned index)
+{
+ assert(t->is_struct() || t->is_interface());
+ assert(index < t->length);
+ return &t->fields.structure[index];
+}
+
}
const struct glsl_struct_field *glsl_get_struct_field_data(const struct glsl_type *t, unsigned index);
unsigned glsl_get_struct_location_offset(const struct glsl_type *t, unsigned length);
int glsl_get_field_index(const struct glsl_type *t, const char *name);
-int glsl_get_struct_field_offset(const struct glsl_type *t, unsigned index);
-const char *glsl_get_struct_elem_name(const struct glsl_type *t, unsigned index);
+
+static inline int
+glsl_get_struct_field_offset(const struct glsl_type *t, unsigned index)
+{
+ return t->fields.structure[index].offset;
+}
+
+static inline const char *
+glsl_get_struct_elem_name(const struct glsl_type *t, unsigned index)
+{
+ return t->fields.structure[index].name;
+}
static inline const struct glsl_type *glsl_void_type(void) { return &glsl_type_builtin_void; }
static inline const struct glsl_type *glsl_float_type(void) { return &glsl_type_builtin_float; }
inline int glsl_type::array_size() const { return glsl_array_size(this); }
inline const glsl_type *glsl_type::without_array() const { return glsl_without_array(this); }
+inline unsigned glsl_type::struct_location_offset(unsigned len) const { return glsl_get_struct_location_offset(this, len); }
+inline int glsl_type::field_index(const char *n) const { return glsl_get_field_index(this, n); }
+
inline unsigned glsl_type::components() const { return glsl_get_components(this); }
inline unsigned glsl_type::component_slots() const { return glsl_get_component_slots(this); }
inline unsigned glsl_type::component_slots_aligned(unsigned int offset) const { return glsl_get_component_slots_aligned(this, offset); }
}
const struct glsl_type *
-glsl_get_struct_field(const struct glsl_type *type, unsigned index)
-{
- assert(type->is_struct() || type->is_interface());
- assert(index < type->length);
- return type->fields.structure[index].type;
-}
-
-int
-glsl_get_struct_field_offset(const struct glsl_type *type,
- unsigned index)
-{
- return type->fields.structure[index].offset;
-}
-
-const struct glsl_struct_field *
-glsl_get_struct_field_data(const struct glsl_type *type, unsigned index)
-{
- assert(type->is_struct() || type->is_interface());
- assert(index < type->length);
- return &type->fields.structure[index];
-}
-
-const struct glsl_type *
glsl_texture_type_to_sampler(const struct glsl_type *type, bool is_shadow)
{
assert(glsl_type_is_texture(type));
return type->base_type;
}
-const char *
-glsl_get_struct_elem_name(const struct glsl_type *type, unsigned index)
-{
- return type->fields.structure[index].name;
-}
-
glsl_sampler_dim
glsl_get_sampler_dim(const struct glsl_type *type)
{
return type->coordinate_components();
}
-unsigned
-glsl_get_struct_location_offset(const struct glsl_type *type,
- unsigned length)
-{
- return type->struct_location_offset(length);
-}
-
bool
glsl_record_compare(const struct glsl_type *a, const struct glsl_type *b,
bool match_name, bool match_locations, bool match_precision)
return glsl_type_count(type, GLSL_TYPE_IMAGE);
}
-int
-glsl_get_field_index(const struct glsl_type *type, const char *name)
-{
- return type->field_index(name);
-}
-
enum glsl_interface_packing
glsl_get_internal_ifc_packing(const struct glsl_type *type,
bool std430_supported)