From: Jason Ekstrand Date: Fri, 13 Nov 2015 23:49:13 +0000 (-0800) Subject: nir/types: Add image type helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0572444a0ec0da1309247c732a0212b3944d8f2b;p=mesa.git nir/types: Add image type helpers --- diff --git a/src/glsl/nir/nir_types.cpp b/src/glsl/nir/nir_types.cpp index 4a1250e546c..27db5793a60 100644 --- a/src/glsl/nir/nir_types.cpp +++ b/src/glsl/nir/nir_types.cpp @@ -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) diff --git a/src/glsl/nir/nir_types.h b/src/glsl/nir/nir_types.h index a61af6cba75..9cc71e899d7 100644 --- a/src/glsl/nir/nir_types.h +++ b/src/glsl/nir/nir_types.h @@ -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);