summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-02-18 11:42:36 -0800
committerJason Ekstrand <[email protected]>2016-02-18 11:42:36 -0800
commit79c0781f44af2a93473c68cf317bb6844f31cfc8 (patch)
tree968f55bd53ad127a1f3ef814bdccc8c9831fbdd7
parente881c73975cb12ce58d4ebc362c6ad18a8e4b3ca (diff)
nir/gather_info: Count textures and images
-rw-r--r--src/compiler/nir/nir_gather_info.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index b84915c2d2b..8f0abd33ce6 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -105,5 +105,22 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
foreach_list_typed(nir_variable, var, node, &shader->system_values)
shader->info.system_values_read |= nir_variable_get_io_mask(var, shader->stage);
+ shader->info.num_textures = 0;
+ shader->info.num_images = 0;
+ nir_foreach_variable(var, &shader->uniforms) {
+ const struct glsl_type *type = var->type;
+ unsigned count = 1;
+ if (glsl_type_is_array(type)) {
+ count = glsl_get_length(type);
+ type = glsl_get_array_element(type);
+ }
+
+ if (glsl_type_is_image(type)) {
+ shader->info.num_images += count;
+ } else if (glsl_type_is_sampler(type)) {
+ shader->info.num_textures += count;
+ }
+ }
+
nir_foreach_block(entrypoint, gather_info_block, shader);
}