summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2019-03-19 15:54:32 -0400
committerRob Clark <[email protected]>2019-03-21 09:13:05 -0400
commitd4cbc946859f56f0a2a50cd8931a6fd29ab22db9 (patch)
tree6e91b41f0490046cbe106f229b8c9f7e5c149a19 /src/compiler
parent8eb16ae8bfb1b8a74b86ea57d6b9e467e30bc4f3 (diff)
nir: move gls_type_get_{sampler,image}_count()
I need at least the sampler variant in ir3.. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_gather_info.c42
-rw-r--r--src/compiler/nir_types.cpp42
-rw-r--r--src/compiler/nir_types.h3
3 files changed, 45 insertions, 42 deletions
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index f2a209028cc..36d0d23bda4 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -332,48 +332,6 @@ gather_info_block(nir_block *block, nir_shader *shader, void *dead_ctx)
}
}
-static unsigned
-glsl_type_get_sampler_count(const struct glsl_type *type)
-{
- if (glsl_type_is_array(type)) {
- return (glsl_get_aoa_size(type) *
- glsl_type_get_sampler_count(glsl_without_array(type)));
- }
-
- if (glsl_type_is_struct_or_ifc(type)) {
- unsigned count = 0;
- for (int i = 0; i < glsl_get_length(type); i++)
- count += glsl_type_get_sampler_count(glsl_get_struct_field(type, i));
- return count;
- }
-
- if (glsl_type_is_sampler(type))
- return 1;
-
- return 0;
-}
-
-static unsigned
-glsl_type_get_image_count(const struct glsl_type *type)
-{
- if (glsl_type_is_array(type)) {
- return (glsl_get_aoa_size(type) *
- glsl_type_get_image_count(glsl_without_array(type)));
- }
-
- if (glsl_type_is_struct_or_ifc(type)) {
- unsigned count = 0;
- for (int i = 0; i < glsl_get_length(type); i++)
- count += glsl_type_get_image_count(glsl_get_struct_field(type, i));
- return count;
- }
-
- if (glsl_type_is_image(type))
- return 1;
-
- return 0;
-}
-
void
nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
{
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index d3e5520cd98..aff575c60b0 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -679,3 +679,45 @@ glsl_get_cl_alignment(const struct glsl_type *type)
{
return type->cl_alignment();
}
+
+unsigned
+glsl_type_get_sampler_count(const struct glsl_type *type)
+{
+ if (glsl_type_is_array(type)) {
+ return (glsl_get_aoa_size(type) *
+ glsl_type_get_sampler_count(glsl_without_array(type)));
+ }
+
+ if (glsl_type_is_struct_or_ifc(type)) {
+ unsigned count = 0;
+ for (int i = 0; i < glsl_get_length(type); i++)
+ count += glsl_type_get_sampler_count(glsl_get_struct_field(type, i));
+ return count;
+ }
+
+ if (glsl_type_is_sampler(type))
+ return 1;
+
+ return 0;
+}
+
+unsigned
+glsl_type_get_image_count(const struct glsl_type *type)
+{
+ if (glsl_type_is_array(type)) {
+ return (glsl_get_aoa_size(type) *
+ glsl_type_get_image_count(glsl_without_array(type)));
+ }
+
+ if (glsl_type_is_struct_or_ifc(type)) {
+ unsigned count = 0;
+ for (int i = 0; i < glsl_get_length(type); i++)
+ count += glsl_type_get_image_count(glsl_get_struct_field(type, i));
+ return count;
+ }
+
+ if (glsl_type_is_image(type))
+ return 1;
+
+ return 0;
+}
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index eeba445a3ba..7bcf4c08f4c 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -197,6 +197,9 @@ void glsl_get_natural_size_align_bytes(const struct glsl_type *type,
const struct glsl_type *glsl_atomic_uint_type(void);
+unsigned glsl_type_get_sampler_count(const struct glsl_type *type);
+unsigned glsl_type_get_image_count(const struct glsl_type *type);
+
#ifdef __cplusplus
}
#endif