nir/types: Add more helpers for creating types

This commit is contained in:
Jason Ekstrand 2015-04-29 14:28:37 -07:00
parent 53bff3e445
commit 5bb94c9b12
2 changed files with 55 additions and 3 deletions

View file

@ -149,9 +149,9 @@ glsl_float_type(void)
}
const glsl_type *
glsl_vec4_type(void)
glsl_int_type(void)
{
return glsl_type::vec4_type;
return glsl_type::int_type;
}
const glsl_type *
@ -160,8 +160,48 @@ glsl_uint_type(void)
return glsl_type::uint_type;
}
const glsl_type *
glsl_bool_type(void)
{
return glsl_type::bool_type;
}
const glsl_type *
glsl_vec4_type(void)
{
return glsl_type::vec4_type;
}
const glsl_type *
glsl_vector_type(enum glsl_base_type base_type, unsigned components)
{
assert(components > 1 && components <= 4);
return glsl_type::get_instance(base_type, components, 1);
}
const glsl_type *
glsl_matrix_type(enum glsl_base_type base_type, unsigned rows, unsigned columns)
{
assert(rows > 1 && rows <= 4 && columns > 1 && columns <= 4);
return glsl_type::get_instance(base_type, rows, columns);
}
const glsl_type *
glsl_array_type(const glsl_type *base, unsigned elements)
{
return glsl_type::get_array_instance(base, elements);
}
const glsl_type *
glsl_struct_type(const glsl_struct_field *fields,
unsigned num_fields, const char *name)
{
return glsl_type::get_record_instance(fields, num_fields, name);
}
const glsl_type *
glsl_function_type(const glsl_type *return_type,
const glsl_function_param *params, unsigned num_params)
{
return glsl_type::get_function_instance(return_type, params, num_params);
}

View file

@ -70,10 +70,22 @@ bool glsl_type_is_matrix(const struct glsl_type *type);
const struct glsl_type *glsl_void_type(void);
const struct glsl_type *glsl_float_type(void);
const struct glsl_type *glsl_vec4_type(void);
const struct glsl_type *glsl_int_type(void);
const struct glsl_type *glsl_uint_type(void);
const struct glsl_type *glsl_bool_type(void);
const struct glsl_type *glsl_vec4_type(void);
const struct glsl_type *glsl_vector_type(enum glsl_base_type base_type,
unsigned components);
const struct glsl_type *glsl_matrix_type(enum glsl_base_type base_type,
unsigned rows, unsigned columns);
const struct glsl_type *glsl_array_type(const struct glsl_type *base,
unsigned elements);
const struct glsl_type *glsl_struct_type(const struct glsl_struct_field *fields,
unsigned num_fields, const char *name);
const struct glsl_type * glsl_function_type(const struct glsl_type *return_type,
const struct glsl_function_param *params,
unsigned num_params);
#ifdef __cplusplus
}