nir/types: Add image type helpers

This commit is contained in:
Jason Ekstrand 2015-11-13 15:49:13 -08:00
parent d5ba7a26d9
commit 0572444a0e
2 changed files with 20 additions and 3 deletions

View file

@ -133,14 +133,14 @@ glsl_get_struct_elem_name(const struct glsl_type *type, unsigned index)
glsl_sampler_dim
glsl_get_sampler_dim(const struct glsl_type *type)
{
assert(glsl_type_is_sampler(type));
assert(glsl_type_is_sampler(type) || glsl_type_is_image(type));
return (glsl_sampler_dim)type->sampler_dimensionality;
}
glsl_base_type
glsl_get_sampler_result_type(const struct glsl_type *type)
{
assert(glsl_type_is_sampler(type));
assert(glsl_type_is_sampler(type) || glsl_type_is_image(type));
return (glsl_base_type)type->sampler_type;
}
@ -199,6 +199,12 @@ glsl_type_is_sampler(const struct glsl_type *type)
return type->is_sampler();
}
bool
glsl_type_is_image(const struct glsl_type *type)
{
return type->is_image();
}
bool
glsl_sampler_type_is_shadow(const struct glsl_type *type)
{
@ -209,7 +215,7 @@ glsl_sampler_type_is_shadow(const struct glsl_type *type)
bool
glsl_sampler_type_is_array(const struct glsl_type *type)
{
assert(glsl_type_is_sampler(type));
assert(glsl_type_is_sampler(type) || glsl_type_is_image(type));
return type->sampler_array;
}
@ -289,6 +295,13 @@ glsl_sampler_type(enum glsl_sampler_dim dim, bool is_shadow, bool is_array,
return glsl_type::get_sampler_instance(dim, is_shadow, is_array, base_type);
}
const struct glsl_type *
glsl_image_type(enum glsl_sampler_dim dim, bool is_array,
enum glsl_base_type base_type)
{
return glsl_type::get_image_instance(dim, is_array, base_type);
}
const glsl_type *
glsl_function_type(const glsl_type *return_type,
const glsl_function_param *params, unsigned num_params)

View file

@ -84,6 +84,7 @@ bool glsl_type_is_matrix(const struct glsl_type *type);
bool glsl_type_is_array(const struct glsl_type *type);
bool glsl_type_is_struct(const struct glsl_type *type);
bool glsl_type_is_sampler(const struct glsl_type *type);
bool glsl_type_is_image(const struct glsl_type *type);
bool glsl_sampler_type_is_shadow(const struct glsl_type *type);
bool glsl_sampler_type_is_array(const struct glsl_type *type);
@ -106,6 +107,9 @@ const struct glsl_type *glsl_struct_type(const struct glsl_struct_field *fields,
const struct glsl_type *glsl_sampler_type(enum glsl_sampler_dim dim,
bool is_shadow, bool is_array,
enum glsl_base_type base_type);
const struct glsl_type *glsl_image_type(enum glsl_sampler_dim dim,
bool is_array,
enum glsl_base_type base_type);
const struct glsl_type * glsl_function_type(const struct glsl_type *return_type,
const struct glsl_function_param *params,
unsigned num_params);