nir/types: Add more helpers for creating types
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 29 Apr 2015 21:28:37 +0000 (14:28 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 16 May 2015 18:16:32 +0000 (11:16 -0700)
src/glsl/nir/nir_types.cpp
src/glsl/nir/nir_types.h

index 62176f5..937a842 100644 (file)
@@ -149,13 +149,59 @@ glsl_float_type(void)
 }
 
 const glsl_type *
+glsl_int_type(void)
+{
+   return glsl_type::int_type;
+}
+
+const glsl_type *
+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);
+}
index 276d4ad..aad43f7 100644 (file)
@@ -70,9 +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_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
 }